55namespace UnitTests \Providers ;
66
77use App \Providers \Foo ;
8+ use DateTime ;
89use DateTimeImmutable ;
910use PHPUnit \Framework \Attributes \CoversClass ;
1011use PHPUnit \Framework \Attributes \DataProvider ;
@@ -17,7 +18,7 @@ final class FooTest extends TestCase
1718{
1819 protected function setUp (): void
1920 {
20- ClockMock::freeze (new \ DateTime ('2024-01-01 00:00:00 ' ));
21+ ClockMock::freeze (new DateTime ('2024-01-01 00:00:00 ' ));
2122 }
2223
2324 protected function tearDown (): void
@@ -29,20 +30,22 @@ protected function tearDown(): void
2930 #[DataProvider('dataProviderForGetDateTime ' )]
3031 public function checkGetDateTime (string $ format ): void
3132 {
32- $ expectedCurrentDateTime = ( new DateTimeImmutable ())-> format ( $ format );
33+ $ datetime = new DateTimeImmutable ();
3334
34- self ::assertEquals ($ expectedCurrentDateTime , Foo::getDateTime ($ format ));
35+ self ::assertEquals ($ datetime -> format ( $ format ) , Foo::getDateTime ($ format ));
3536 }
3637
3738 /**
3839 * @return array<string, array<int, string>>
3940 */
4041 public static function dataProviderForGetDateTime (): array
4142 {
43+ $ datetime = new DateTimeImmutable ();
44+
4245 return [
43- '[CURRENT DATE TIME] ' => ['Y-m-d H:i:s ' ],
44- '[CURRENT DATE] ' => ['Y-m-d ' ],
45- '[CURRENT TIME] ' => ['H:i:s ' ],
46+ '[CURRENT DATE TIME] ' => [$ datetime -> format ( 'Y-m-d H:i:s ' ) ],
47+ '[CURRENT DATE] ' => [$ datetime -> format ( 'Y-m-d ' ) ],
48+ '[CURRENT TIME] ' => [$ datetime -> format ( 'H:i:s ' ) ],
4649 ];
4750 }
4851
0 commit comments