Тут вопрос в том, будет ли логика в классе, например, Discipline, или инфа по сути справочная, т.к. на текущий момент информация там выглядит не очень связно.А что именно там не так?
Ну, во первых - почему константы торчат наружу(public)?
А во вторых, что такое Event Discipline из вашего кода ну никак не ясно, как не ясно....
.. почему эту инфу не поместить в агрегат Discipline
$this->expectExceptionMessage('Price already exists.');
$discipline->addPrice(
$priceId = PriceId::next(),
$date = new Date($currentDate, $currentDate->modify('+1 day')),
$price = 120,
$currency = 'RUB',
$calculator = Price::CALCULATOR_TYPE_REGISTRATION
);
public function addPrice(PriceId $id, Date $date, int $value, string $currency, string $calculator): void
{
foreach ($this->prices as $current) {
if ($current->getDate()->getStart() >= $date->getStart() && $date->getStart() <= $current->getDate()->getEnd()) {
throw new \DomainException('Price already exists.');
}
if ($current->getDate()->getStart() >= $date->getEnd() && $date->getEnd() <= $current->getDate()->getEnd()) {
throw new \DomainException('Price already exists.');
}
}
$this->prices->add(new Price($this, $id, $date, $value, $currency, $calculator));
}
public function testExists(): void
{
$currentDate = new \DateTimeImmutable('+1 day');
$event = (new EventBuilder())->activate()->build();
$discipline = (new DisciplineBuilder())->build();
$discipline = Discipline::create($event, new Id($discipline->getId()->getValue()));
$discipline->addPrice(
$priceId = PriceId::next(),
$date = new Date($currentDate->modify('+4 day'), $currentDate->modify('+5 day')),
$price = 100,
$currency = 'RUB',
$calculator = Price::CALCULATOR_TYPE_PERSON
);
$this->expectExceptionMessage('Price already exists.');
$discipline->addPrice(
$priceId = PriceId::next(),
$date = new Date($currentDate, $currentDate->modify('+1 day')),
$price = 120,
$currency = 'RUB',
$calculator = Price::CALCULATOR_TYPE_REGISTRATION
);
}
__main__
и теперь определяет)) Спасибо большое!) Вообще не знал, что так нужно прописывать namespace. Где это написано? Читал не видел.проблема в неймспесах, они изменились :facepalm: