1
+ <?php
2
+
3
+ namespace Youshido \Tests \Issues \Issue90 ;
4
+
5
+ use Youshido \GraphQL \Execution \Processor ;
6
+ use Youshido \Tests \Issues \Issue90 \Issue90Schema ;
7
+
8
+ /**
9
+ * User: stefano.corallo
10
+ * Date: 25/11/16
11
+ * Time: 9.39
12
+ */
13
+ class Issue90Test extends \PHPUnit_Framework_TestCase
14
+ {
15
+
16
+ public function testQueryDateTimeTypeWithDateParameter ()
17
+ {
18
+ $ schema = new Issue90Schema ();
19
+ $ processor = new Processor ($ schema );
20
+ $ processor ->processPayload ("query{ echo(date: \"2016-11-25 09:53am \") } " );
21
+ $ res = $ processor ->getResponseData ();
22
+
23
+ self ::assertCount (1 , $ res , "Invalid response array received " ); //only data expected
24
+
25
+ self ::assertNotNull ($ res ['data ' ]['echo ' ], "Invalid echo response received " );
26
+
27
+ self ::assertEquals ("2016-11-25 09:53am " , $ res ['data ' ]['echo ' ]);
28
+ }
29
+
30
+ public function testQueryDateTimeTypeWithoutParameter ()
31
+ {
32
+ $ processor = new Processor (new Issue90Schema ());
33
+ $ processor ->processPayload ("query{ echo } " );
34
+ $ res = $ processor ->getResponseData ();
35
+
36
+ self ::assertCount (1 , $ res , "Invalid response array received " ); //only data expected
37
+
38
+ self ::assertNull ($ res ['data ' ]['echo ' ]);
39
+ }
40
+
41
+ public function testQueryDateTimeTypeWithNullParameter ()
42
+ {
43
+ $ processor = new Processor (new Issue90Schema ());
44
+ $ processor ->processPayload ("query{ echo(date: null) } " );
45
+ $ res = $ processor ->getResponseData ();
46
+
47
+ self ::assertCount (1 , $ res , "Invalid response array received " ); //only data expected
48
+
49
+ self ::assertNull ($ res ['data ' ]['echo ' ], "Error Quering with explicit date null parameter " );
50
+ }
51
+
52
+ public function testMutatingDateTimeWithParameter ()
53
+ {
54
+ $ schema = new Issue90Schema ();
55
+ $ processor = new Processor ($ schema );
56
+ $ processor ->processPayload ("mutation{ echo(date: \"2016-11-25 09:53am \") } " );
57
+ $ res = $ processor ->getResponseData ();
58
+
59
+ self ::assertCount (1 , $ res , "Invalid response array received " ); //only data expected
60
+
61
+ self ::assertNotNull ($ res ['data ' ]['echo ' ], "Invalid echo response received during mutation of date parameter " );
62
+
63
+ self ::assertEquals ("2016-11-25 09:53am " , $ res ['data ' ]['echo ' ]);
64
+ }
65
+
66
+ public function testMutatingDateTimeWithExplicitNullParameter ()
67
+ {
68
+ $ schema = new Issue90Schema ();
69
+ $ processor = new Processor ($ schema );
70
+ $ processor ->processPayload ("mutation{ echo(date: null) } " );
71
+ $ res = $ processor ->getResponseData ();
72
+
73
+ self ::assertCount (1 , $ res , "Invalid response array received " ); //only data expected
74
+ self ::assertNull ($ res ['data ' ]['echo ' ], "Invalid echo response received during mutation of date parameter with explicit null value " );
75
+ }
76
+ }
0 commit comments