/** @test */ public function an_activity_isnt_rescheduled_when_the_same_period_is_given() { $id = ActivityId::generate(); $this->scenario->withAggregateId($id)->given([$this->socialActivityWasPlanned($id, ['schedule' => Schedule::forPeriod(new DateTimeImmutable('2015-10-03 14:30'), new DateTimeImmutable('2015-10-03 15:30'))])])->when(function ($activity) { return $activity->reschedule(Schedule::forPeriod(new DateTimeImmutable('2015-10-03 14:30'), new DateTimeImmutable('2015-10-03 15:30'))); })->then([]); // It should also be idempotent when repeatedly rescheduling an activity $this->scenario->withAggregateId($id)->given([$this->socialActivityWasPlanned($id), new ActivityRescheduled($id, Schedule::forPeriod(new DateTimeImmutable('2015-10-03 14:30'), new DateTimeImmutable('2015-10-03 15:30')))])->when(function ($activity) { return $activity->reschedule(Schedule::forPeriod(new DateTimeImmutable('2015-10-03 14:30'), new DateTimeImmutable('2015-10-03 15:30'))); })->then([]); }
protected function createInstance() { return new ActivityRescheduled(ActivityId::generate(), Schedule::forPeriod(new DateTimeImmutable('2015-10-03 14:30'), new DateTimeImmutable('2015-10-03 15:30'))); }
/** * @test */ public function the_end_time_and_the_start_time_cant_be_identical() { $this->expectException(InvalidArgumentException::class); $time = new DateTimeImmutable('2015-03-10 10:00'); $schedule = Schedule::forPeriod($time, $time); }