@@ -22,12 +22,17 @@ final class ConstraintValidatorTest extends TestCase
22
22
*/
23
23
public function testFormatValue ($ expected , $ value , $ format = 0 )
24
24
{
25
+ $ default = date_default_timezone_get ();
26
+ date_default_timezone_set ('Europe/Moscow ' );
27
+
25
28
$ this ->assertSame ($ expected , (new TestFormatValueConstraintValidator ())->formatValueProxy ($ value , $ format ));
29
+
30
+ date_default_timezone_set ($ default );
26
31
}
27
32
28
33
public function formatValueProvider ()
29
34
{
30
- $ data = [
35
+ return [
31
36
['true ' , true ],
32
37
['false ' , false ],
33
38
['null ' , null ],
@@ -36,11 +41,11 @@ public function formatValueProvider()
36
41
['array ' , []],
37
42
['object ' , $ toString = new TestToStringObject ()],
38
43
['ccc ' , $ toString , ConstraintValidator::OBJECT_TO_STRING ],
39
- ['object ' , $ dateTime = (new \DateTimeImmutable ('@0 ' ))->setTimezone (new \DateTimeZone ('UTC ' ))],
40
- [class_exists (\IntlDateFormatter::class) ? 'Jan 1, 1970, 12:00 AM ' : '1970-01-01 00:00:00 ' , $ dateTime , ConstraintValidator::PRETTY_DATE ],
44
+ ['object ' , (new \DateTimeImmutable ('@0 ' ))->setTimezone (new \DateTimeZone ('UTC ' ))],
45
+ [class_exists (\IntlDateFormatter::class) ? 'Oct 4, 2019, 11:02 AM ' : '2019-10-04 11:02:03 ' , new \DateTimeImmutable ('2019-10-04T11:02:03+09:00 ' ), ConstraintValidator::PRETTY_DATE ],
46
+ [class_exists (\IntlDateFormatter::class) ? 'Feb 2, 1971, 8:00 AM ' : '1971-02-02 08:00:00 ' , (new \DateTimeImmutable ('1971-02-02T08:00:00 ' ))->setTimezone (new \DateTimeZone ('UTC ' )), ConstraintValidator::PRETTY_DATE ],
47
+ [class_exists (\IntlDateFormatter::class) ? 'Jan 1, 1970, 6:00 AM ' : '1970-01-01 6:00:00 ' , (new \DateTimeImmutable ('1970-01-01T06:00:00 ' ))->setTimezone (new \DateTimeZone ('Z ' )), ConstraintValidator::PRETTY_DATE ],
41
48
];
42
-
43
- return $ data ;
44
49
}
45
50
}
46
51
0 commit comments