@@ -17,7 +17,7 @@ class DateTimeToStringTransformerTest extends DateTimeTestCase
17
17
{
18
18
public function dataProvider ()
19
19
{
20
- return array (
20
+ $ data = array (
21
21
array ('Y-m-d H:i:s ' , '2010-02-03 16:05:06 ' , '2010-02-03 16:05:06 UTC ' ),
22
22
array ('Y-m-d H:i:00 ' , '2010-02-03 16:05:00 ' , '2010-02-03 16:05:00 UTC ' ),
23
23
array ('Y-m-d H:i ' , '2010-02-03 16:05 ' , '2010-02-03 16:05:00 UTC ' ),
@@ -33,10 +33,12 @@ public function dataProvider()
33
33
34
34
// different day representations
35
35
array ('Y-m-j ' , '2010-02-3 ' , '2010-02-03 00:00:00 UTC ' ),
36
- array ('Y-z ' , '2010-33 ' , '2010-02-03 00:00:00 UTC ' ),
37
36
array ('z ' , '33 ' , '1970-02-03 00:00:00 UTC ' ),
38
37
39
38
// not bijective
39
+ // this will not work as php will use actual date to replace missing info
40
+ // and after change of date will lookup for closest Wednesday
41
+ // i.e. value: 2010-02, php value: 2010-02-(today i.e. 20), parsed date: 2010-02-24
40
42
//array('Y-m-D', '2010-02-Wed', '2010-02-03 00:00:00 UTC'),
41
43
//array('Y-m-l', '2010-02-Wednesday', '2010-02-03 00:00:00 UTC'),
42
44
@@ -56,6 +58,13 @@ public function dataProvider()
56
58
// seconds since unix
57
59
array ('U ' , '1265213106 ' , '2010-02-03 16:05:06 UTC ' ),
58
60
);
61
+
62
+ // This test will fail < 5.3.9 - see https://bugs.php.net/51994
63
+ if (version_compare (phpversion (), '5.3.9 ' , '>= ' )) {
64
+ $ data [] = array ('Y-z ' , '2010-33 ' , '2010-02-03 00:00:00 UTC ' );
65
+ }
66
+
67
+ return $ data ;
59
68
}
60
69
61
70
/**
@@ -100,8 +109,12 @@ public function testTransformExpectsDateTime()
100
109
/**
101
110
* @dataProvider dataProvider
102
111
*/
103
- public function testReverseTransformBeforePhp538 ($ format , $ input , $ output )
112
+ public function testReverseTransformUsingPipe ($ format , $ input , $ output )
104
113
{
114
+ if (version_compare (phpversion (), '5.3.7 ' , '>= ' )) {
115
+ $ this ->markTestSkipped ('Pipe usage requires PHP 5.3.7 or newer. ' );
116
+ }
117
+
105
118
$ reverseTransformer = new DateTimeToStringTransformer ('UTC ' , 'UTC ' , $ format , false );
106
119
107
120
$ output = new \DateTime ($ output );
@@ -112,13 +125,9 @@ public function testReverseTransformBeforePhp538($format, $input, $output)
112
125
/**
113
126
* @dataProvider dataProvider
114
127
*/
115
- public function testReverseTransformAsOfPhp538 ($ format , $ input , $ output )
128
+ public function testReverseTransformWithoutUsingPipe ($ format , $ input , $ output )
116
129
{
117
- if (version_compare (phpversion (), '5.3.8 ' , '< ' )) {
118
- $ this ->markTestSkipped ('Requires PHP 5.3.8 or newer ' );
119
- }
120
-
121
- $ reverseTransformer = new DateTimeToStringTransformer ('UTC ' , 'UTC ' , $ format );
130
+ $ reverseTransformer = new DateTimeToStringTransformer ('UTC ' , 'UTC ' , $ format , false );
122
131
123
132
$ output = new \DateTime ($ output );
124
133
0 commit comments