1919use DateInterval ;
2020use DatePeriod ;
2121use DateTime ;
22+ use InvalidArgumentException ;
2223
2324class ChronosDatePeriodTest extends TestCase
2425{
@@ -30,11 +31,37 @@ public function testChronosPeriod(): void
3031 $ output [$ key ] = $ value ;
3132 }
3233 $ this ->assertCount (4 , $ output );
33- $ this ->assertInstanceOf (ChronosDAte ::class, $ output [0 ]);
34+ $ this ->assertInstanceOf (ChronosDate ::class, $ output [0 ]);
3435 $ this ->assertSame ('2025-01-01 00:00:00 ' , $ output [0 ]->format ('Y-m-d H:i:s ' ));
3536 $ this ->assertInstanceOf (ChronosDate::class, $ output [1 ]);
3637 $ this ->assertSame ('2025-01-02 00:00:00 ' , $ output [1 ]->format ('Y-m-d H:i:s ' ));
3738 $ this ->assertInstanceOf (ChronosDate::class, $ output [3 ]);
3839 $ this ->assertSame ('2025-01-04 00:00:00 ' , $ output [3 ]->format ('Y-m-d H:i:s ' ));
3940 }
41+
42+ public function testZeroIntervalThrowsException (): void
43+ {
44+ $ this ->expectException (InvalidArgumentException::class);
45+ $ this ->expectExceptionMessage ('Cannot create a period with a zero interval ' );
46+
47+ $ period = new DatePeriod (
48+ new DateTime ('2025-01-01 ' ),
49+ new DateInterval ('PT0S ' ),
50+ new DateTime ('2025-01-02 ' ),
51+ );
52+ new ChronosDatePeriod ($ period );
53+ }
54+
55+ public function testZeroIntervalAllZeroComponents (): void
56+ {
57+ $ this ->expectException (InvalidArgumentException::class);
58+
59+ $ interval = new DateInterval ('P0D ' );
60+ $ period = new DatePeriod (
61+ new DateTime ('2025-01-01 ' ),
62+ $ interval ,
63+ new DateTime ('2025-01-02 ' ),
64+ );
65+ new ChronosDatePeriod ($ period );
66+ }
4067}
0 commit comments