@@ -27,7 +27,7 @@ class DateCasterTest extends TestCase
27
27
/**
28
28
* @dataProvider provideDateTimes
29
29
*/
30
- public function testDumpDateTime ($ time , $ timezone , $ expected )
30
+ public function testDumpDateTime ($ time , $ timezone , $ xDate , $ xTimestamp )
31
31
{
32
32
if ((defined ('HHVM_VERSION_ID ' ) || PHP_VERSION_ID <= 50509 ) && preg_match ('/[-+]\d{2}:\d{2}/ ' , $ timezone )) {
33
33
$ this ->markTestSkipped ('DateTimeZone GMT offsets are supported since 5.5.10. See https://github.com/facebook/hhvm/issues/5875 for HHVM. ' );
@@ -36,37 +36,40 @@ public function testDumpDateTime($time, $timezone, $expected)
36
36
$ date = new \DateTime ($ time , new \DateTimeZone ($ timezone ));
37
37
38
38
$ xDump = <<<EODUMP
39
- DateTime @1493503200 {
40
- date: $ expected
39
+ DateTime @ $ xTimestamp {
40
+ date: $ xDate
41
41
}
42
42
EODUMP ;
43
43
44
- $ this ->assertDumpMatchesFormat ($ xDump , $ date );
44
+ $ this ->assertDumpEquals ($ xDump , $ date );
45
45
}
46
46
47
- public function testCastDateTime ()
47
+ /**
48
+ * @dataProvider provideDateTimes
49
+ */
50
+ public function testCastDateTime ($ time , $ timezone , $ xDate , $ xTimestamp , $ xInfos )
48
51
{
52
+ if ((defined ('HHVM_VERSION_ID ' ) || PHP_VERSION_ID <= 50509 ) && preg_match ('/[-+]\d{2}:\d{2}/ ' , $ timezone )) {
53
+ $ this ->markTestSkipped ('DateTimeZone GMT offsets are supported since 5.5.10. See https://github.com/facebook/hhvm/issues/5875 for HHVM. ' );
54
+ }
55
+
49
56
$ stub = new Stub ();
50
- $ date = new \DateTime (' 2017-08-30 00:00:00.000000 ' , new \DateTimeZone (' Europe/Zurich ' ));
57
+ $ date = new \DateTime ($ time , new \DateTimeZone ($ timezone ));
51
58
$ cast = DateCaster::castDateTime ($ date , array ('foo ' => 'bar ' ), $ stub , false , 0 );
52
59
53
- $ xDump = <<<' EODUMP'
60
+ $ xDump = <<<EODUMP
54
61
array:1 [
55
- "\x00~\x00date" => 2017-08-30 00:00:00.0 Europe/Zurich (+02:00)
62
+ "\\ x00~\\ x00date" => $ xDate
56
63
]
57
64
EODUMP ;
58
65
59
- $ this ->assertDumpMatchesFormat ($ xDump , $ cast );
66
+ $ this ->assertDumpEquals ($ xDump , $ cast );
60
67
61
- $ xDump = <<<' EODUMP'
68
+ $ xDump = <<<EODUMP
62
69
Symfony\Component\VarDumper\Caster\ConstStub {
63
70
+type: 1
64
- +class: "2017-08-30 00:00:00.0 Europe/Zurich (+02:00)"
65
- +value: """
66
- Wednesday, August 30, 2017\n
67
- +%a from now\n
68
- DST On
69
- """
71
+ +class: " $ xDate"
72
+ +value: "%A $ xInfos%A"
70
73
+cut: 0
71
74
+handle: 0
72
75
+refCount: 0
@@ -81,15 +84,16 @@ public function testCastDateTime()
81
84
public function provideDateTimes ()
82
85
{
83
86
return array (
84
- array ('2017-04-30 00:00:00.000000 ' , 'Europe/Zurich ' , '2017-04-30 00:00:00.0 Europe/Zurich (+02:00) ' ),
85
- array ('2017-04-30 00:00:00.000000 ' , '+02:00 ' , '2017-04-30 00:00:00.0 +02:00 ' ),
86
-
87
- array ('2017-04-30 00:00:00.100000 ' , '+02:00 ' , '2017-04-30 00:00:00.100 +02:00 ' ),
88
- array ('2017-04-30 00:00:00.120000 ' , '+02:00 ' , '2017-04-30 00:00:00.120 +02:00 ' ),
89
- array ('2017-04-30 00:00:00.123000 ' , '+02:00 ' , '2017-04-30 00:00:00.123 +02:00 ' ),
90
- array ('2017-04-30 00:00:00.123400 ' , '+02:00 ' , '2017-04-30 00:00:00.123400 +02:00 ' ),
91
- array ('2017-04-30 00:00:00.123450 ' , '+02:00 ' , '2017-04-30 00:00:00.123450 +02:00 ' ),
92
- array ('2017-04-30 00:00:00.123456 ' , '+02:00 ' , '2017-04-30 00:00:00.123456 +02:00 ' ),
87
+ array ('2017-04-30 00:00:00.000000 ' , 'Europe/Zurich ' , '2017-04-30 00:00:00.0 Europe/Zurich (+02:00) ' , 1493503200 , 'Sunday, April 30, 2017%Afrom now%ADST On ' ),
88
+ array ('2017-12-31 00:00:00.000000 ' , 'Europe/Zurich ' , '2017-12-31 00:00:00.0 Europe/Zurich (+01:00) ' , 1514674800 , 'Sunday, December 31, 2017%Afrom now%ADST Off ' ),
89
+ array ('2017-04-30 00:00:00.000000 ' , '+02:00 ' , '2017-04-30 00:00:00.0 +02:00 ' , 1493503200 , 'Sunday, April 30, 2017%Afrom now ' ),
90
+
91
+ array ('2017-04-30 00:00:00.100000 ' , '+00:00 ' , '2017-04-30 00:00:00.100 +00:00 ' , 1493510400 , 'Sunday, April 30, 2017%Afrom now ' ),
92
+ array ('2017-04-30 00:00:00.120000 ' , '+00:00 ' , '2017-04-30 00:00:00.120 +00:00 ' , 1493510400 , 'Sunday, April 30, 2017%Afrom now ' ),
93
+ array ('2017-04-30 00:00:00.123000 ' , '+00:00 ' , '2017-04-30 00:00:00.123 +00:00 ' , 1493510400 , 'Sunday, April 30, 2017%Afrom now ' ),
94
+ array ('2017-04-30 00:00:00.123400 ' , '+00:00 ' , '2017-04-30 00:00:00.123400 +00:00 ' , 1493510400 , 'Sunday, April 30, 2017%Afrom now ' ),
95
+ array ('2017-04-30 00:00:00.123450 ' , '+00:00 ' , '2017-04-30 00:00:00.123450 +00:00 ' , 1493510400 , 'Sunday, April 30, 2017%Afrom now ' ),
96
+ array ('2017-04-30 00:00:00.123456 ' , '+00:00 ' , '2017-04-30 00:00:00.123456 +00:00 ' , 1493510400 , 'Sunday, April 30, 2017%Afrom now ' ),
93
97
);
94
98
}
95
99
@@ -124,7 +128,7 @@ public function testDumpIntervalExcludingVerbosity($intervalSpec, $invert, $expe
124
128
}
125
129
EODUMP ;
126
130
127
- $ this ->assertDumpMatchesFormat ($ xDump , $ interval , Caster::EXCLUDE_VERBOSE );
131
+ $ this ->assertDumpEquals ($ xDump , $ interval , Caster::EXCLUDE_VERBOSE );
128
132
}
129
133
130
134
/**
@@ -144,7 +148,7 @@ public function testCastInterval($intervalSpec, $invert, $xInterval, $xSeconds)
144
148
]
145
149
EODUMP ;
146
150
147
- $ this ->assertDumpMatchesFormat ($ xDump , $ cast );
151
+ $ this ->assertDumpEquals ($ xDump , $ cast );
148
152
149
153
if (null === $ xSeconds ) {
150
154
return ;
@@ -163,7 +167,7 @@ public function testCastInterval($intervalSpec, $invert, $xInterval, $xSeconds)
163
167
}
164
168
EODUMP ;
165
169
166
- $ this ->assertDumpMatchesFormat ($ xDump , $ cast ["\0~ \0interval " ]);
170
+ $ this ->assertDumpEquals ($ xDump , $ cast ["\0~ \0interval " ]);
167
171
}
168
172
169
173
public function provideIntervals ()
@@ -229,7 +233,7 @@ public function testDumpTimeZoneExcludingVerbosity($timezone, $expected)
229
233
}
230
234
EODUMP ;
231
235
232
- $ this ->assertDumpMatchesFormat ($ xDump , $ timezone , Caster::EXCLUDE_VERBOSE );
236
+ $ this ->assertDumpEquals ($ xDump , $ timezone , Caster::EXCLUDE_VERBOSE );
233
237
}
234
238
235
239
/**
@@ -252,7 +256,7 @@ public function testCastTimeZone($timezone, $xTimezone, $xRegion)
252
256
]
253
257
EODUMP ;
254
258
255
- $ this ->assertDumpMatchesFormat ($ xDump , $ cast );
259
+ $ this ->assertDumpEquals ($ xDump , $ cast );
256
260
257
261
$ xDump = <<<EODUMP
258
262
Symfony\Component\VarDumper\Caster\ConstStub {
0 commit comments