Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/var-dumper/Tests/Caster/DateCasterTest.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | 7a779792577d |
children |
comparison
equal
deleted
inserted
replaced
16:c2387f117808 | 17:129ea1e6d783 |
---|---|
27 /** | 27 /** |
28 * @dataProvider provideDateTimes | 28 * @dataProvider provideDateTimes |
29 */ | 29 */ |
30 public function testDumpDateTime($time, $timezone, $xDate, $xTimestamp) | 30 public function testDumpDateTime($time, $timezone, $xDate, $xTimestamp) |
31 { | 31 { |
32 if ((defined('HHVM_VERSION_ID') || PHP_VERSION_ID <= 50509) && preg_match('/[-+]\d{2}:\d{2}/', $timezone)) { | 32 if ((\defined('HHVM_VERSION_ID') || \PHP_VERSION_ID <= 50509) && preg_match('/[-+]\d{2}:\d{2}/', $timezone)) { |
33 $this->markTestSkipped('DateTimeZone GMT offsets are supported since 5.5.10. See https://github.com/facebook/hhvm/issues/5875 for HHVM.'); | 33 $this->markTestSkipped('DateTimeZone GMT offsets are supported since 5.5.10. See https://github.com/facebook/hhvm/issues/5875 for HHVM.'); |
34 } | 34 } |
35 | 35 |
36 $date = new \DateTime($time, new \DateTimeZone($timezone)); | 36 $date = new \DateTime($time, new \DateTimeZone($timezone)); |
37 | 37 |
47 /** | 47 /** |
48 * @dataProvider provideDateTimes | 48 * @dataProvider provideDateTimes |
49 */ | 49 */ |
50 public function testCastDateTime($time, $timezone, $xDate, $xTimestamp, $xInfos) | 50 public function testCastDateTime($time, $timezone, $xDate, $xTimestamp, $xInfos) |
51 { | 51 { |
52 if ((defined('HHVM_VERSION_ID') || PHP_VERSION_ID <= 50509) && preg_match('/[-+]\d{2}:\d{2}/', $timezone)) { | 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.'); | 53 $this->markTestSkipped('DateTimeZone GMT offsets are supported since 5.5.10. See https://github.com/facebook/hhvm/issues/5875 for HHVM.'); |
54 } | 54 } |
55 | 55 |
56 $stub = new Stub(); | 56 $stub = new Stub(); |
57 $date = new \DateTime($time, new \DateTimeZone($timezone)); | 57 $date = new \DateTime($time, new \DateTimeZone($timezone)); |
58 $cast = DateCaster::castDateTime($date, array('foo' => 'bar'), $stub, false, 0); | 58 $cast = DateCaster::castDateTime($date, ['foo' => 'bar'], $stub, false, 0); |
59 | 59 |
60 $xDump = <<<EODUMP | 60 $xDump = <<<EODUMP |
61 array:1 [ | 61 array:1 [ |
62 "\\x00~\\x00date" => $xDate | 62 "\\x00~\\x00date" => $xDate |
63 ] | 63 ] |
81 $this->assertDumpMatchesFormat($xDump, $cast["\0~\0date"]); | 81 $this->assertDumpMatchesFormat($xDump, $cast["\0~\0date"]); |
82 } | 82 } |
83 | 83 |
84 public function provideDateTimes() | 84 public function provideDateTimes() |
85 { | 85 { |
86 return array( | 86 return [ |
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'), | 87 ['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'), | 88 ['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'), | 89 ['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 | 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'), | 91 ['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'), | 92 ['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'), | 93 ['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'), | 94 ['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'), | 95 ['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'), | 96 ['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'], |
97 ); | 97 ]; |
98 } | 98 } |
99 | 99 |
100 /** | 100 /** |
101 * @dataProvider provideIntervals | 101 * @dataProvider provideIntervals |
102 */ | 102 */ |
103 public function testDumpInterval($intervalSpec, $ms, $invert, $expected) | 103 public function testDumpInterval($intervalSpec, $ms, $invert, $expected) |
104 { | 104 { |
105 if ($ms && PHP_VERSION_ID >= 70200 && version_compare(PHP_VERSION, '7.2.0rc3', '<=')) { | 105 if ($ms && \PHP_VERSION_ID >= 70200 && version_compare(PHP_VERSION, '7.2.0rc3', '<=')) { |
106 $this->markTestSkipped('Skipped on 7.2 before rc4 because of php bug #75354.'); | 106 $this->markTestSkipped('Skipped on 7.2 before rc4 because of php bug #75354.'); |
107 } | 107 } |
108 | 108 |
109 $interval = $this->createInterval($intervalSpec, $ms, $invert); | 109 $interval = $this->createInterval($intervalSpec, $ms, $invert); |
110 | 110 |
120 /** | 120 /** |
121 * @dataProvider provideIntervals | 121 * @dataProvider provideIntervals |
122 */ | 122 */ |
123 public function testDumpIntervalExcludingVerbosity($intervalSpec, $ms, $invert, $expected) | 123 public function testDumpIntervalExcludingVerbosity($intervalSpec, $ms, $invert, $expected) |
124 { | 124 { |
125 if ($ms && PHP_VERSION_ID >= 70200 && version_compare(PHP_VERSION, '7.2.0rc3', '<=')) { | 125 if ($ms && \PHP_VERSION_ID >= 70200 && version_compare(PHP_VERSION, '7.2.0rc3', '<=')) { |
126 $this->markTestSkipped('Skipped on 7.2 before rc4 because of php bug #75354.'); | 126 $this->markTestSkipped('Skipped on 7.2 before rc4 because of php bug #75354.'); |
127 } | 127 } |
128 | 128 |
129 $interval = $this->createInterval($intervalSpec, $ms, $invert); | 129 $interval = $this->createInterval($intervalSpec, $ms, $invert); |
130 | 130 |
140 /** | 140 /** |
141 * @dataProvider provideIntervals | 141 * @dataProvider provideIntervals |
142 */ | 142 */ |
143 public function testCastInterval($intervalSpec, $ms, $invert, $xInterval, $xSeconds) | 143 public function testCastInterval($intervalSpec, $ms, $invert, $xInterval, $xSeconds) |
144 { | 144 { |
145 if ($ms && PHP_VERSION_ID >= 70200 && version_compare(PHP_VERSION, '7.2.0rc3', '<=')) { | 145 if ($ms && \PHP_VERSION_ID >= 70200 && version_compare(PHP_VERSION, '7.2.0rc3', '<=')) { |
146 $this->markTestSkipped('Skipped on 7.2 before rc4 because of php bug #75354.'); | 146 $this->markTestSkipped('Skipped on 7.2 before rc4 because of php bug #75354.'); |
147 } | 147 } |
148 | 148 |
149 $interval = $this->createInterval($intervalSpec, $ms, $invert); | 149 $interval = $this->createInterval($intervalSpec, $ms, $invert); |
150 $stub = new Stub(); | 150 $stub = new Stub(); |
151 | 151 |
152 $cast = DateCaster::castInterval($interval, array('foo' => 'bar'), $stub, false, Caster::EXCLUDE_VERBOSE); | 152 $cast = DateCaster::castInterval($interval, ['foo' => 'bar'], $stub, false, Caster::EXCLUDE_VERBOSE); |
153 | 153 |
154 $xDump = <<<EODUMP | 154 $xDump = <<<EODUMP |
155 array:1 [ | 155 array:1 [ |
156 "\\x00~\\x00interval" => $xInterval | 156 "\\x00~\\x00interval" => $xInterval |
157 ] | 157 ] |
182 public function provideIntervals() | 182 public function provideIntervals() |
183 { | 183 { |
184 $i = new \DateInterval('PT0S'); | 184 $i = new \DateInterval('PT0S'); |
185 $ms = ($withMs = \PHP_VERSION_ID >= 70100 && isset($i->f)) ? '.0' : ''; | 185 $ms = ($withMs = \PHP_VERSION_ID >= 70100 && isset($i->f)) ? '.0' : ''; |
186 | 186 |
187 return array( | 187 return [ |
188 array('PT0S', 0, 0, '0s', '0s'), | 188 ['PT0S', 0, 0, '0s', '0s'], |
189 array('PT0S', 0.1, 0, $withMs ? '+ 00:00:00.100' : '0s', '%is'), | 189 ['PT0S', 0.1, 0, $withMs ? '+ 00:00:00.100' : '0s', '%is'], |
190 array('PT1S', 0, 0, '+ 00:00:01'.$ms, '%is'), | 190 ['PT1S', 0, 0, '+ 00:00:01'.$ms, '%is'], |
191 array('PT2M', 0, 0, '+ 00:02:00'.$ms, '%is'), | 191 ['PT2M', 0, 0, '+ 00:02:00'.$ms, '%is'], |
192 array('PT3H', 0, 0, '+ 03:00:00'.$ms, '%ss'), | 192 ['PT3H', 0, 0, '+ 03:00:00'.$ms, '%ss'], |
193 array('P4D', 0, 0, '+ 4d', '%ss'), | 193 ['P4D', 0, 0, '+ 4d', '%ss'], |
194 array('P5M', 0, 0, '+ 5m', null), | 194 ['P5M', 0, 0, '+ 5m', null], |
195 array('P6Y', 0, 0, '+ 6y', null), | 195 ['P6Y', 0, 0, '+ 6y', null], |
196 array('P1Y2M3DT4H5M6S', 0, 0, '+ 1y 2m 3d 04:05:06'.$ms, null), | 196 ['P1Y2M3DT4H5M6S', 0, 0, '+ 1y 2m 3d 04:05:06'.$ms, null], |
197 array('PT1M60S', 0, 0, '+ 00:02:00'.$ms, null), | 197 ['PT1M60S', 0, 0, '+ 00:02:00'.$ms, null], |
198 array('PT1H60M', 0, 0, '+ 02:00:00'.$ms, null), | 198 ['PT1H60M', 0, 0, '+ 02:00:00'.$ms, null], |
199 array('P1DT24H', 0, 0, '+ 2d', null), | 199 ['P1DT24H', 0, 0, '+ 2d', null], |
200 array('P1M32D', 0, 0, '+ 1m 32d', null), | 200 ['P1M32D', 0, 0, '+ 1m 32d', null], |
201 | 201 |
202 array('PT0S', 0, 1, '0s', '0s'), | 202 ['PT0S', 0, 1, '0s', '0s'], |
203 array('PT0S', 0.1, 1, $withMs ? '- 00:00:00.100' : '0s', '%is'), | 203 ['PT0S', 0.1, 1, $withMs ? '- 00:00:00.100' : '0s', '%is'], |
204 array('PT1S', 0, 1, '- 00:00:01'.$ms, '%is'), | 204 ['PT1S', 0, 1, '- 00:00:01'.$ms, '%is'], |
205 array('PT2M', 0, 1, '- 00:02:00'.$ms, '%is'), | 205 ['PT2M', 0, 1, '- 00:02:00'.$ms, '%is'], |
206 array('PT3H', 0, 1, '- 03:00:00'.$ms, '%ss'), | 206 ['PT3H', 0, 1, '- 03:00:00'.$ms, '%ss'], |
207 array('P4D', 0, 1, '- 4d', '%ss'), | 207 ['P4D', 0, 1, '- 4d', '%ss'], |
208 array('P5M', 0, 1, '- 5m', null), | 208 ['P5M', 0, 1, '- 5m', null], |
209 array('P6Y', 0, 1, '- 6y', null), | 209 ['P6Y', 0, 1, '- 6y', null], |
210 array('P1Y2M3DT4H5M6S', 0, 1, '- 1y 2m 3d 04:05:06'.$ms, null), | 210 ['P1Y2M3DT4H5M6S', 0, 1, '- 1y 2m 3d 04:05:06'.$ms, null], |
211 array('PT1M60S', 0, 1, '- 00:02:00'.$ms, null), | 211 ['PT1M60S', 0, 1, '- 00:02:00'.$ms, null], |
212 array('PT1H60M', 0, 1, '- 02:00:00'.$ms, null), | 212 ['PT1H60M', 0, 1, '- 02:00:00'.$ms, null], |
213 array('P1DT24H', 0, 1, '- 2d', null), | 213 ['P1DT24H', 0, 1, '- 2d', null], |
214 array('P1M32D', 0, 1, '- 1m 32d', null), | 214 ['P1M32D', 0, 1, '- 1m 32d', null], |
215 ); | 215 ]; |
216 } | 216 } |
217 | 217 |
218 /** | 218 /** |
219 * @dataProvider provideTimeZones | 219 * @dataProvider provideTimeZones |
220 */ | 220 */ |
221 public function testDumpTimeZone($timezone, $expected) | 221 public function testDumpTimeZone($timezone, $expected) |
222 { | 222 { |
223 if ((defined('HHVM_VERSION_ID') || PHP_VERSION_ID <= 50509) && !preg_match('/\w+\/\w+/', $timezone)) { | 223 if ((\defined('HHVM_VERSION_ID') || \PHP_VERSION_ID <= 50509) && !preg_match('/\w+\/\w+/', $timezone)) { |
224 $this->markTestSkipped('DateTimeZone GMT offsets are supported since 5.5.10. See https://github.com/facebook/hhvm/issues/5875 for HHVM.'); | 224 $this->markTestSkipped('DateTimeZone GMT offsets are supported since 5.5.10. See https://github.com/facebook/hhvm/issues/5875 for HHVM.'); |
225 } | 225 } |
226 | 226 |
227 $timezone = new \DateTimeZone($timezone); | 227 $timezone = new \DateTimeZone($timezone); |
228 | 228 |
238 /** | 238 /** |
239 * @dataProvider provideTimeZones | 239 * @dataProvider provideTimeZones |
240 */ | 240 */ |
241 public function testDumpTimeZoneExcludingVerbosity($timezone, $expected) | 241 public function testDumpTimeZoneExcludingVerbosity($timezone, $expected) |
242 { | 242 { |
243 if ((defined('HHVM_VERSION_ID') || PHP_VERSION_ID <= 50509) && !preg_match('/\w+\/\w+/', $timezone)) { | 243 if ((\defined('HHVM_VERSION_ID') || \PHP_VERSION_ID <= 50509) && !preg_match('/\w+\/\w+/', $timezone)) { |
244 $this->markTestSkipped('DateTimeZone GMT offsets are supported since 5.5.10. See https://github.com/facebook/hhvm/issues/5875 for HHVM.'); | 244 $this->markTestSkipped('DateTimeZone GMT offsets are supported since 5.5.10. See https://github.com/facebook/hhvm/issues/5875 for HHVM.'); |
245 } | 245 } |
246 | 246 |
247 $timezone = new \DateTimeZone($timezone); | 247 $timezone = new \DateTimeZone($timezone); |
248 | 248 |
258 /** | 258 /** |
259 * @dataProvider provideTimeZones | 259 * @dataProvider provideTimeZones |
260 */ | 260 */ |
261 public function testCastTimeZone($timezone, $xTimezone, $xRegion) | 261 public function testCastTimeZone($timezone, $xTimezone, $xRegion) |
262 { | 262 { |
263 if ((defined('HHVM_VERSION_ID') || PHP_VERSION_ID <= 50509) && !preg_match('/\w+\/\w+/', $timezone)) { | 263 if ((\defined('HHVM_VERSION_ID') || \PHP_VERSION_ID <= 50509) && !preg_match('/\w+\/\w+/', $timezone)) { |
264 $this->markTestSkipped('DateTimeZone GMT offsets are supported since 5.5.10. See https://github.com/facebook/hhvm/issues/5875 for HHVM.'); | 264 $this->markTestSkipped('DateTimeZone GMT offsets are supported since 5.5.10. See https://github.com/facebook/hhvm/issues/5875 for HHVM.'); |
265 } | 265 } |
266 | 266 |
267 $timezone = new \DateTimeZone($timezone); | 267 $timezone = new \DateTimeZone($timezone); |
268 $stub = new Stub(); | 268 $stub = new Stub(); |
269 | 269 |
270 $cast = DateCaster::castTimeZone($timezone, array('foo' => 'bar'), $stub, false, Caster::EXCLUDE_VERBOSE); | 270 $cast = DateCaster::castTimeZone($timezone, ['foo' => 'bar'], $stub, false, Caster::EXCLUDE_VERBOSE); |
271 | 271 |
272 $xDump = <<<EODUMP | 272 $xDump = <<<EODUMP |
273 array:1 [ | 273 array:1 [ |
274 "\\x00~\\x00timezone" => $xTimezone | 274 "\\x00~\\x00timezone" => $xTimezone |
275 ] | 275 ] |
293 $this->assertDumpMatchesFormat($xDump, $cast["\0~\0timezone"]); | 293 $this->assertDumpMatchesFormat($xDump, $cast["\0~\0timezone"]); |
294 } | 294 } |
295 | 295 |
296 public function provideTimeZones() | 296 public function provideTimeZones() |
297 { | 297 { |
298 $xRegion = extension_loaded('intl') ? '%s' : ''; | 298 $xRegion = \extension_loaded('intl') ? '%s' : ''; |
299 | 299 |
300 return array( | 300 return [ |
301 // type 1 (UTC offset) | 301 // type 1 (UTC offset) |
302 array('-12:00', '-12:00', ''), | 302 ['-12:00', '-12:00', ''], |
303 array('+00:00', '+00:00', ''), | 303 ['+00:00', '+00:00', ''], |
304 array('+14:00', '+14:00', ''), | 304 ['+14:00', '+14:00', ''], |
305 | 305 |
306 // type 2 (timezone abbreviation) | 306 // type 2 (timezone abbreviation) |
307 array('GMT', '+00:00', ''), | 307 ['GMT', '+00:00', ''], |
308 array('a', '+01:00', ''), | 308 ['a', '+01:00', ''], |
309 array('b', '+02:00', ''), | 309 ['b', '+02:00', ''], |
310 array('z', '+00:00', ''), | 310 ['z', '+00:00', ''], |
311 | 311 |
312 // type 3 (timezone identifier) | 312 // type 3 (timezone identifier) |
313 array('Africa/Tunis', 'Africa/Tunis (%s:00)', $xRegion), | 313 ['Africa/Tunis', 'Africa/Tunis (%s:00)', $xRegion], |
314 array('America/Panama', 'America/Panama (%s:00)', $xRegion), | 314 ['America/Panama', 'America/Panama (%s:00)', $xRegion], |
315 array('Asia/Jerusalem', 'Asia/Jerusalem (%s:00)', $xRegion), | 315 ['Asia/Jerusalem', 'Asia/Jerusalem (%s:00)', $xRegion], |
316 array('Atlantic/Canary', 'Atlantic/Canary (%s:00)', $xRegion), | 316 ['Atlantic/Canary', 'Atlantic/Canary (%s:00)', $xRegion], |
317 array('Australia/Perth', 'Australia/Perth (%s:00)', $xRegion), | 317 ['Australia/Perth', 'Australia/Perth (%s:00)', $xRegion], |
318 array('Europe/Zurich', 'Europe/Zurich (%s:00)', $xRegion), | 318 ['Europe/Zurich', 'Europe/Zurich (%s:00)', $xRegion], |
319 array('Pacific/Tahiti', 'Pacific/Tahiti (%s:00)', $xRegion), | 319 ['Pacific/Tahiti', 'Pacific/Tahiti (%s:00)', $xRegion], |
320 ); | 320 ]; |
321 } | 321 } |
322 | 322 |
323 /** | 323 /** |
324 * @dataProvider providePeriods | 324 * @dataProvider providePeriods |
325 */ | 325 */ |
326 public function testDumpPeriod($start, $interval, $end, $options, $expected) | 326 public function testDumpPeriod($start, $interval, $end, $options, $expected) |
327 { | 327 { |
328 if (defined('HHVM_VERSION_ID') || \PHP_VERSION_ID < 50620 || (\PHP_VERSION_ID >= 70000 && \PHP_VERSION_ID < 70005)) { | 328 if (\defined('HHVM_VERSION_ID') || \PHP_VERSION_ID < 50620 || (\PHP_VERSION_ID >= 70000 && \PHP_VERSION_ID < 70005)) { |
329 $this->markTestSkipped(); | 329 $this->markTestSkipped(); |
330 } | 330 } |
331 | 331 |
332 $p = new \DatePeriod(new \DateTime($start), new \DateInterval($interval), is_int($end) ? $end : new \DateTime($end), $options); | 332 $p = new \DatePeriod(new \DateTime($start), new \DateInterval($interval), \is_int($end) ? $end : new \DateTime($end), $options); |
333 | 333 |
334 $xDump = <<<EODUMP | 334 $xDump = <<<EODUMP |
335 DatePeriod { | 335 DatePeriod { |
336 period: $expected | 336 period: $expected |
337 %A} | 337 %A} |
343 /** | 343 /** |
344 * @dataProvider providePeriods | 344 * @dataProvider providePeriods |
345 */ | 345 */ |
346 public function testCastPeriod($start, $interval, $end, $options, $xPeriod, $xDates) | 346 public function testCastPeriod($start, $interval, $end, $options, $xPeriod, $xDates) |
347 { | 347 { |
348 if (defined('HHVM_VERSION_ID') || \PHP_VERSION_ID < 50620 || (\PHP_VERSION_ID >= 70000 && \PHP_VERSION_ID < 70005)) { | 348 if (\defined('HHVM_VERSION_ID') || \PHP_VERSION_ID < 50620 || (\PHP_VERSION_ID >= 70000 && \PHP_VERSION_ID < 70005)) { |
349 $this->markTestSkipped(); | 349 $this->markTestSkipped(); |
350 } | 350 } |
351 | 351 |
352 $p = new \DatePeriod(new \DateTime($start), new \DateInterval($interval), is_int($end) ? $end : new \DateTime($end), $options); | 352 $p = new \DatePeriod(new \DateTime($start), new \DateInterval($interval), \is_int($end) ? $end : new \DateTime($end), $options); |
353 $stub = new Stub(); | 353 $stub = new Stub(); |
354 | 354 |
355 $cast = DateCaster::castPeriod($p, array(), $stub, false, 0); | 355 $cast = DateCaster::castPeriod($p, [], $stub, false, 0); |
356 | 356 |
357 $xDump = <<<EODUMP | 357 $xDump = <<<EODUMP |
358 array:1 [ | 358 array:1 [ |
359 "\\x00~\\x00period" => $xPeriod | 359 "\\x00~\\x00period" => $xPeriod |
360 ] | 360 ] |
381 public function providePeriods() | 381 public function providePeriods() |
382 { | 382 { |
383 $i = new \DateInterval('PT0S'); | 383 $i = new \DateInterval('PT0S'); |
384 $ms = \PHP_VERSION_ID >= 70100 && isset($i->f) ? '.0' : ''; | 384 $ms = \PHP_VERSION_ID >= 70100 && isset($i->f) ? '.0' : ''; |
385 | 385 |
386 $periods = array( | 386 $periods = [ |
387 array('2017-01-01', 'P1D', '2017-01-03', 0, 'every + 1d, from 2017-01-01 00:00:00.0 (included) to 2017-01-03 00:00:00.0', '1) 2017-01-01%a2) 2017-01-02'), | 387 ['2017-01-01', 'P1D', '2017-01-03', 0, 'every + 1d, from 2017-01-01 00:00:00.0 (included) to 2017-01-03 00:00:00.0', '1) 2017-01-01%a2) 2017-01-02'], |
388 array('2017-01-01', 'P1D', 1, 0, 'every + 1d, from 2017-01-01 00:00:00.0 (included) recurring 2 time/s', '1) 2017-01-01%a2) 2017-01-02'), | 388 ['2017-01-01', 'P1D', 1, 0, 'every + 1d, from 2017-01-01 00:00:00.0 (included) recurring 2 time/s', '1) 2017-01-01%a2) 2017-01-02'], |
389 | 389 |
390 array('2017-01-01', 'P1D', '2017-01-04', 0, 'every + 1d, from 2017-01-01 00:00:00.0 (included) to 2017-01-04 00:00:00.0', '1) 2017-01-01%a2) 2017-01-02%a3) 2017-01-03'), | 390 ['2017-01-01', 'P1D', '2017-01-04', 0, 'every + 1d, from 2017-01-01 00:00:00.0 (included) to 2017-01-04 00:00:00.0', '1) 2017-01-01%a2) 2017-01-02%a3) 2017-01-03'], |
391 array('2017-01-01', 'P1D', 2, 0, 'every + 1d, from 2017-01-01 00:00:00.0 (included) recurring 3 time/s', '1) 2017-01-01%a2) 2017-01-02%a3) 2017-01-03'), | 391 ['2017-01-01', 'P1D', 2, 0, 'every + 1d, from 2017-01-01 00:00:00.0 (included) recurring 3 time/s', '1) 2017-01-01%a2) 2017-01-02%a3) 2017-01-03'], |
392 | 392 |
393 array('2017-01-01', 'P1D', '2017-01-05', 0, 'every + 1d, from 2017-01-01 00:00:00.0 (included) to 2017-01-05 00:00:00.0', '1) 2017-01-01%a2) 2017-01-02%a1 more'), | 393 ['2017-01-01', 'P1D', '2017-01-05', 0, 'every + 1d, from 2017-01-01 00:00:00.0 (included) to 2017-01-05 00:00:00.0', '1) 2017-01-01%a2) 2017-01-02%a1 more'], |
394 array('2017-01-01', 'P1D', 3, 0, 'every + 1d, from 2017-01-01 00:00:00.0 (included) recurring 4 time/s', '1) 2017-01-01%a2) 2017-01-02%a3) 2017-01-03%a1 more'), | 394 ['2017-01-01', 'P1D', 3, 0, 'every + 1d, from 2017-01-01 00:00:00.0 (included) recurring 4 time/s', '1) 2017-01-01%a2) 2017-01-02%a3) 2017-01-03%a1 more'], |
395 | 395 |
396 array('2017-01-01', 'P1D', '2017-01-21', 0, 'every + 1d, from 2017-01-01 00:00:00.0 (included) to 2017-01-21 00:00:00.0', '1) 2017-01-01%a17 more'), | 396 ['2017-01-01', 'P1D', '2017-01-21', 0, 'every + 1d, from 2017-01-01 00:00:00.0 (included) to 2017-01-21 00:00:00.0', '1) 2017-01-01%a17 more'], |
397 array('2017-01-01', 'P1D', 19, 0, 'every + 1d, from 2017-01-01 00:00:00.0 (included) recurring 20 time/s', '1) 2017-01-01%a17 more'), | 397 ['2017-01-01', 'P1D', 19, 0, 'every + 1d, from 2017-01-01 00:00:00.0 (included) recurring 20 time/s', '1) 2017-01-01%a17 more'], |
398 | 398 |
399 array('2017-01-01 01:00:00', 'P1D', '2017-01-03 01:00:00', 0, 'every + 1d, from 2017-01-01 01:00:00.0 (included) to 2017-01-03 01:00:00.0', '1) 2017-01-01 01:00:00.0%a2) 2017-01-02 01:00:00.0'), | 399 ['2017-01-01 01:00:00', 'P1D', '2017-01-03 01:00:00', 0, 'every + 1d, from 2017-01-01 01:00:00.0 (included) to 2017-01-03 01:00:00.0', '1) 2017-01-01 01:00:00.0%a2) 2017-01-02 01:00:00.0'], |
400 array('2017-01-01 01:00:00', 'P1D', 1, 0, 'every + 1d, from 2017-01-01 01:00:00.0 (included) recurring 2 time/s', '1) 2017-01-01 01:00:00.0%a2) 2017-01-02 01:00:00.0'), | 400 ['2017-01-01 01:00:00', 'P1D', 1, 0, 'every + 1d, from 2017-01-01 01:00:00.0 (included) recurring 2 time/s', '1) 2017-01-01 01:00:00.0%a2) 2017-01-02 01:00:00.0'], |
401 | 401 |
402 array('2017-01-01', 'P1DT1H', '2017-01-03', 0, "every + 1d 01:00:00$ms, from 2017-01-01 00:00:00.0 (included) to 2017-01-03 00:00:00.0", '1) 2017-01-01 00:00:00.0%a2) 2017-01-02 01:00:00.0'), | 402 ['2017-01-01', 'P1DT1H', '2017-01-03', 0, "every + 1d 01:00:00$ms, from 2017-01-01 00:00:00.0 (included) to 2017-01-03 00:00:00.0", '1) 2017-01-01 00:00:00.0%a2) 2017-01-02 01:00:00.0'], |
403 array('2017-01-01', 'P1DT1H', 1, 0, "every + 1d 01:00:00$ms, from 2017-01-01 00:00:00.0 (included) recurring 2 time/s", '1) 2017-01-01 00:00:00.0%a2) 2017-01-02 01:00:00.0'), | 403 ['2017-01-01', 'P1DT1H', 1, 0, "every + 1d 01:00:00$ms, from 2017-01-01 00:00:00.0 (included) recurring 2 time/s", '1) 2017-01-01 00:00:00.0%a2) 2017-01-02 01:00:00.0'], |
404 | 404 |
405 array('2017-01-01', 'P1D', '2017-01-04', \DatePeriod::EXCLUDE_START_DATE, 'every + 1d, from 2017-01-01 00:00:00.0 (excluded) to 2017-01-04 00:00:00.0', '1) 2017-01-02%a2) 2017-01-03'), | 405 ['2017-01-01', 'P1D', '2017-01-04', \DatePeriod::EXCLUDE_START_DATE, 'every + 1d, from 2017-01-01 00:00:00.0 (excluded) to 2017-01-04 00:00:00.0', '1) 2017-01-02%a2) 2017-01-03'], |
406 array('2017-01-01', 'P1D', 2, \DatePeriod::EXCLUDE_START_DATE, 'every + 1d, from 2017-01-01 00:00:00.0 (excluded) recurring 2 time/s', '1) 2017-01-02%a2) 2017-01-03'), | 406 ['2017-01-01', 'P1D', 2, \DatePeriod::EXCLUDE_START_DATE, 'every + 1d, from 2017-01-01 00:00:00.0 (excluded) recurring 2 time/s', '1) 2017-01-02%a2) 2017-01-03'], |
407 ); | 407 ]; |
408 | 408 |
409 if (\PHP_VERSION_ID < 70107) { | 409 if (\PHP_VERSION_ID < 70107) { |
410 array_walk($periods, function (&$i) { $i[5] = ''; }); | 410 array_walk($periods, function (&$i) { $i[5] = ''; }); |
411 } | 411 } |
412 | 412 |