55namespace AssoConnect \PHPDate \Tests ;
66
77use AssoConnect \PHPDate \AbsoluteDate ;
8- use AssoConnect \ PHPDate \ Exception \ ParsingException ;
8+ use DateMalformedStringException ;
99use PHPUnit \Framework \TestCase ;
10+ use Symfony \Component \Clock \DatePoint ;
1011
1112class AbsoluteDateTest extends TestCase
1213{
1314 public function testParsingException (): void
1415 {
15- $ this ->expectException (ParsingException ::class);
16+ $ this ->expectException (DateMalformedStringException ::class);
1617 new AbsoluteDate ('abc ' , 'def ' );
1718 }
1819
@@ -79,12 +80,11 @@ public function testWithPointInTime(): void
7980 $ date = new AbsoluteDate ('2020-01-02 ' );
8081 self ::assertSame ('2020-01-02 ' , $ date ->format ());
8182
82- $ datetime = \DateTime ::createFromFormat (
83+ $ datetime = DatePoint ::createFromFormat (
8384 'Y-m-d H:i:s ' ,
8485 '2019-12-27 23:00:00 ' ,
8586 new \DateTimeZone ('UTC ' )
8687 );
87- self ::assertNotFalse ($ datetime );
8888
8989 $ date = AbsoluteDate::createInTimezone (new \DateTimeZone ('UTC ' ), $ datetime );
9090 self ::assertSame ('2019-12-27 ' , $ date ->format ());
@@ -98,13 +98,13 @@ public function testWithPointInTime(): void
9898
9999 public function testStartsAt (): void
100100 {
101- $ date1 = \DateTime ::createFromFormat (
101+ $ date1 = DatePoint ::createFromFormat (
102102 'Y-m-d H:i:s ' ,
103103 '2019-12-27 00:00:00 ' ,
104104 new \DateTimeZone ('Europe/Paris ' )
105105 );
106106
107- $ date2 = \DateTime ::createFromFormat (
107+ $ date2 = DatePoint ::createFromFormat (
108108 'Y-m-d H:i:s ' ,
109109 '2019-12-27 00:00:00 ' ,
110110 new \DateTimeZone ('America/Los_Angeles ' )
@@ -118,13 +118,13 @@ public function testStartsAt(): void
118118
119119 public function testEndsAt (): void
120120 {
121- $ date1 = \DateTime ::createFromFormat (
121+ $ date1 = DatePoint ::createFromFormat (
122122 'Y-m-d H:i:s ' ,
123123 '2019-12-27 23:59:59 ' ,
124124 new \DateTimeZone ('Europe/Paris ' )
125125 );
126126
127- $ date2 = \DateTime ::createFromFormat (
127+ $ date2 = DatePoint ::createFromFormat (
128128 'Y-m-d H:i:s ' ,
129129 '2019-12-27 23:59:59 ' ,
130130 new \DateTimeZone ('America/Los_Angeles ' )
@@ -142,7 +142,7 @@ public function testEndsAt(): void
142142 public function testCreateRelative (): void
143143 {
144144 $ date = AbsoluteDate::createRelative ('yesterday ' , $ timezone = new \DateTimeZone ('America/Los_Angeles ' ));
145- $ now = new \ DateTimeImmutable ('yesterday ' , $ timezone );
145+ $ now = new DatePoint ('yesterday ' , $ timezone );
146146 self ::assertSame ($ now ->format (AbsoluteDate::DEFAULT_DATE_FORMAT ), $ date ->format ());
147147 }
148148
0 commit comments