@@ -66,29 +66,38 @@ public static function provideDateTimeFieldNames()
66
66
yield ['publish_time ' ];
67
67
}
68
68
69
- public function testDatesThatShouldBeCastAsDateTimeObjectsAreDetected ()
69
+ /**
70
+ * @dataProvider provideValidDateTimeFieldValues
71
+ */
72
+ public function testIsCastDateTimeFieldValueToDateTime ($ value , $ message )
70
73
{
71
- $ graphNode = new GraphNode ();
74
+ $ graphNode = new GraphNode ([ ' created_time ' => $ value ] );
72
75
73
- // Should pass
74
- $ shouldPass = $ graphNode ->isIso8601DateString ('1985-10-26T01:21:00+0000 ' );
75
- $ this ->assertTrue ($ shouldPass , 'Expected the valid ISO 8601 formatted date from Back To The Future to pass. ' );
76
-
77
- $ shouldPass = $ graphNode ->isIso8601DateString ('1999-12-31 ' );
78
- $ this ->assertTrue ($ shouldPass , 'Expected the valid ISO 8601 formatted date to party like it \'s 1999. ' );
76
+ $ this ->assertInstanceOf (\DateTime::class, $ graphNode ->getField ('created_time ' ), $ message );
77
+ }
79
78
80
- $ shouldPass = $ graphNode ->isIso8601DateString ('2009-05-19T14:39Z ' );
81
- $ this ->assertTrue ($ shouldPass , 'Expected the valid ISO 8601 formatted date to pass. ' );
79
+ public static function provideValidDateTimeFieldValues ()
80
+ {
81
+ yield ['1985-10-26T01:21:00+0000 ' , 'Expected the valid ISO 8601 formatted date from Back To The Future to pass. ' ];
82
+ yield ['1999-12-31 ' , 'Expected the valid ISO 8601 formatted date to party like it \'s 1999. ' ];
83
+ yield ['2009-05-19T14:39Z ' , 'Expected the valid ISO 8601 formatted date to pass. ' ];
84
+ yield ['2014-W36 ' , 'Expected the valid ISO 8601 formatted date to pass. ' ];
85
+ }
82
86
83
- $ shouldPass = $ graphNode ->isIso8601DateString ('2014-W36 ' );
84
- $ this ->assertTrue ($ shouldPass , 'Expected the valid ISO 8601 formatted date to pass. ' );
87
+ /**
88
+ * @dataProvider provideInvalidDateTimeFieldValues
89
+ */
90
+ public function testIsNotCastDateTimeFieldValueToDateTime ($ value , $ message )
91
+ {
92
+ $ graphNode = new GraphNode (['created_time ' => $ value ]);
85
93
86
- // Should fail
87
- $ shouldFail = $ graphNode ->isIso8601DateString ('2009-05-19T14a39r ' );
88
- $ this ->assertFalse ($ shouldFail , 'Expected the invalid ISO 8601 format to fail. ' );
94
+ $ this ->assertNotInstanceOf (\DateTime::class, $ graphNode ->getField ('created_time ' ), $ message );
95
+ }
89
96
90
- $ shouldFail = $ graphNode ->isIso8601DateString ('foo_time ' );
91
- $ this ->assertFalse ($ shouldFail , 'Expected the invalid ISO 8601 format to fail. ' );
97
+ public static function provideInvalidDateTimeFieldValues ()
98
+ {
99
+ yield ['2009-05-19T14a39r ' , 'Expected the invalid ISO 8601 format to fail. ' ];
100
+ yield ['foo_time ' , 'Expected the invalid ISO 8601 format to fail. ' ];
92
101
}
93
102
94
103
public function testATimeStampCanBeConvertedToADateTimeObject ()
0 commit comments