start = new DateTime('2026-01-01'); $this->end = new DateTime('2026-01-31'); }); it('creates a valid period', function (): void { // GIVEN / WHEN $period = new Period( $this->start, $this->end ); // THEN expect($period)->toBeInstanceOf(Period::class) ->and($period->start)->toBe($this->start) ->and($period->end)->toBe($this->end); }); it('accepts a period whose end equals its start', function (): void { // GIVEN $start = new DateTime('2026-01-01'); $end = new DateTime('2026-01-01'); // WHEN $period = new Period($start, $end); // THEN expect($period->start)->toBe($start) ->and($period->end)->toBe($end); }); it('throws when the end is before the start', function (): void { // GIVEN / WHEN / THEN expect(fn () => new Period(new DateTime('2026-02-01'), new DateTime('2026-01-01'))) ->toThrow(\DomainException::class, 'Period end date cannot be before its start date.'); }); });