1--TEST--
2Test __set_state magic method for recreating a DatePeriod object
3--CREDITS--
4Mark Baker mark@lange.demon.co.uk at the PHPNW2017 Conference for PHP Testfest 2017
5--FILE--
6<?php
7
8$datePeriodObject = new DatePeriod(
9    new DateTime('2017-10-06 23:30', new DateTimeZone('UTC')),
10    new DateInterval('PT1H30M'),
11    24
12);
13
14$datePeriodState = var_export($datePeriodObject, true);
15
16eval("\$datePeriodObjectNew = {$datePeriodState};");
17
18var_dump($datePeriodObjectNew);
19
20?>
21--EXPECTF--
22object(DatePeriod)#%d (6) {
23  ["start"]=>
24  object(DateTime)#%d (3) {
25    ["date"]=>
26    string(26) "2017-10-06 23:30:00.000000"
27    ["timezone_type"]=>
28    int(3)
29    ["timezone"]=>
30    string(3) "UTC"
31  }
32  ["current"]=>
33  NULL
34  ["end"]=>
35  NULL
36  ["interval"]=>
37  object(DateInterval)#%d (16) {
38    ["y"]=>
39    int(0)
40    ["m"]=>
41    int(0)
42    ["d"]=>
43    int(0)
44    ["h"]=>
45    int(1)
46    ["i"]=>
47    int(30)
48    ["s"]=>
49    int(0)
50    ["f"]=>
51    float(0)
52    ["weekday"]=>
53    int(0)
54    ["weekday_behavior"]=>
55    int(0)
56    ["first_last_day_of"]=>
57    int(0)
58    ["invert"]=>
59    int(0)
60    ["days"]=>
61    bool(false)
62    ["special_type"]=>
63    int(0)
64    ["special_amount"]=>
65    int(0)
66    ["have_weekday_relative"]=>
67    int(0)
68    ["have_special_relative"]=>
69    int(0)
70  }
71  ["recurrences"]=>
72  int(25)
73  ["include_start_date"]=>
74  bool(true)
75}
76