File tree Expand file tree Collapse file tree 2 files changed +45
-22
lines changed Expand file tree Collapse file tree 2 files changed +45
-22
lines changed Original file line number Diff line number Diff line change @@ -275,28 +275,6 @@ public function isIso8601DateString($string)
275
275
return preg_match ($ crazyInsaneRegexThatSomehowDetectsIso8601 , $ string ) === 1 ;
276
276
}
277
277
278
- /**
279
- * Determines if a value from Graph should be cast to DateTime.
280
- *
281
- * @param string $key
282
- *
283
- * @return bool
284
- */
285
- public function shouldCastAsDateTime ($ key )
286
- {
287
- return in_array ($ key , [
288
- 'created_time ' ,
289
- 'updated_time ' ,
290
- 'start_time ' ,
291
- 'stop_time ' ,
292
- 'end_time ' ,
293
- 'backdated_time ' ,
294
- 'issued_at ' ,
295
- 'expires_at ' ,
296
- 'publish_time '
297
- ], true );
298
- }
299
-
300
278
/**
301
279
* Casts a date value from Graph to DateTime.
302
280
*
@@ -337,4 +315,26 @@ public static function getNodeMap()
337
315
{
338
316
return static ::$ graphNodeMap ;
339
317
}
318
+
319
+ /**
320
+ * Determines if a value from Graph should be cast to DateTime.
321
+ *
322
+ * @param string $key
323
+ *
324
+ * @return bool
325
+ */
326
+ private function shouldCastAsDateTime ($ key )
327
+ {
328
+ return in_array ($ key , [
329
+ 'created_time ' ,
330
+ 'updated_time ' ,
331
+ 'start_time ' ,
332
+ 'stop_time ' ,
333
+ 'end_time ' ,
334
+ 'backdated_time ' ,
335
+ 'issued_at ' ,
336
+ 'expires_at ' ,
337
+ 'publish_time '
338
+ ], true );
339
+ }
340
340
}
Original file line number Diff line number Diff line change @@ -43,6 +43,29 @@ public function testAGraphNodeCanInstantiateWithData()
43
43
$ this ->assertEquals (['foo ' => 'bar ' ], $ backingData );
44
44
}
45
45
46
+ /**
47
+ * @dataProvider provideDateTimeFieldNames
48
+ */
49
+ public function testIsCastDateTimeFieldsToDateTime ($ fieldName )
50
+ {
51
+ $ graphNode = new GraphNode ([$ fieldName => '1989-11-02 ' ]);
52
+
53
+ $ this ->assertInstanceOf (\DateTime::class, $ graphNode ->getField ($ fieldName ));
54
+ }
55
+
56
+ public static function provideDateTimeFieldNames ()
57
+ {
58
+ yield ['created_time ' ];
59
+ yield ['updated_time ' ];
60
+ yield ['start_time ' ];
61
+ yield ['stop_time ' ];
62
+ yield ['end_time ' ];
63
+ yield ['backdated_time ' ];
64
+ yield ['issued_at ' ];
65
+ yield ['expires_at ' ];
66
+ yield ['publish_time ' ];
67
+ }
68
+
46
69
public function testDatesThatShouldBeCastAsDateTimeObjectsAreDetected ()
47
70
{
48
71
$ graphNode = new GraphNode ();
You can’t perform that action at this time.
0 commit comments