@@ -51,9 +51,13 @@ public function testInit(): AProtocol
5151 */
5252 public function testNull (AProtocol $ protocol )
5353 {
54- $ protocol ->run ('RETURN $n IS NULL ' , ['n ' => null ], ['mode ' => 'r ' ]);
55- $ res = $ protocol ->pullAll ();
56- $ this ->assertTrue ($ res [0 ][0 ]);
54+ try {
55+ $ protocol ->run ('RETURN $n IS NULL ' , ['n ' => null ], ['mode ' => 'r ' ]);
56+ $ res = $ protocol ->pullAll ();
57+ $ this ->assertTrue ($ res [0 ][0 ]);
58+ } catch (Exception $ e ) {
59+ $ this ->markTestIncomplete ($ e ->getMessage ());
60+ }
5761 }
5862
5963 /**
@@ -62,13 +66,17 @@ public function testNull(AProtocol $protocol)
6266 */
6367 public function testBoolean (AProtocol $ protocol )
6468 {
65- $ protocol ->run ('RETURN $b = true ' , ['b ' => true ], ['mode ' => 'r ' ]);
66- $ res = $ protocol ->pullAll ();
67- $ this ->assertTrue ($ res [0 ][0 ]);
69+ try {
70+ $ protocol ->run ('RETURN $b = true ' , ['b ' => true ], ['mode ' => 'r ' ]);
71+ $ res = $ protocol ->pullAll ();
72+ $ this ->assertTrue ($ res [0 ][0 ]);
6873
69- $ protocol ->run ('RETURN $b = false ' , ['b ' => false ], ['mode ' => 'r ' ]);
70- $ res = $ protocol ->pullAll ();
71- $ this ->assertTrue ($ res [0 ][0 ]);
74+ $ protocol ->run ('RETURN $b = false ' , ['b ' => false ], ['mode ' => 'r ' ]);
75+ $ res = $ protocol ->pullAll ();
76+ $ this ->assertTrue ($ res [0 ][0 ]);
77+ } catch (Exception $ e ) {
78+ $ this ->markTestIncomplete ($ e ->getMessage ());
79+ }
7280 }
7381
7482 /**
@@ -81,13 +89,17 @@ public function testInteger(AProtocol $protocol)
8189 range (-16 , 127 ),
8290 [-17 , -128 , 128 , 32767 , 32768 , 2147483647 , 2147483648 , 9223372036854775807 , -129 , -32768 , -32769 , -2147483648 , -2147483649 , -9223372036854775808 ]
8391 );
84- $ protocol ->run ('RETURN ' . implode (', ' , array_map (function (int $ key , int $ value ) {
85- return '$ ' . $ key . ' = ' . $ value ;
86- }, array_keys ($ arr ), $ arr )), $ arr , ['mode ' => 'r ' ]);
87- $ res = $ protocol ->pullAll ();
92+ try {
93+ $ protocol ->run ('RETURN ' . implode (', ' , array_map (function (int $ key , int $ value ) {
94+ return '$ ' . $ key . ' = ' . $ value ;
95+ }, array_keys ($ arr ), $ arr )), $ arr , ['mode ' => 'r ' ]);
96+ $ res = $ protocol ->pullAll ();
8897
89- foreach ($ arr as $ i => $ _ ) {
90- $ this ->assertTrue ($ res [0 ][$ i ]);
98+ foreach ($ arr as $ i => $ _ ) {
99+ $ this ->assertTrue ($ res [0 ][$ i ]);
100+ }
101+ } catch (Exception $ e ) {
102+ $ this ->markTestIncomplete ($ e ->getMessage ());
91103 }
92104 }
93105
@@ -99,9 +111,13 @@ public function testFloat(AProtocol $protocol)
99111 {
100112 for ($ i = 0 ; $ i < 10 ; $ i ++) {
101113 $ num = mt_rand (-mt_getrandmax (), mt_getrandmax ()) / mt_getrandmax ();
102- $ protocol ->run ('RETURN ' . $ num . ' + 0.000001 > $n > ' . $ num . ' - 0.000001 ' , ['n ' => $ num ], ['mode ' => 'r ' ]); //epsilon comparison
103- $ res = $ protocol ->pullAll ();
104- $ this ->assertTrue ($ res [0 ][0 ]);
114+ try {
115+ $ protocol ->run ('RETURN ' . $ num . ' + 0.000001 > $n > ' . $ num . ' - 0.000001 ' , ['n ' => $ num ], ['mode ' => 'r ' ]); //epsilon comparison
116+ $ res = $ protocol ->pullAll ();
117+ $ this ->assertTrue ($ res [0 ][0 ]);
118+ } catch (Exception $ e ) {
119+ $ this ->markTestIncomplete ($ e ->getMessage ());
120+ }
105121 }
106122 }
107123
@@ -120,9 +136,13 @@ public function testString(AProtocol $protocol)
120136
121137 foreach ([0 , 10 , 200 , 60000 , 200000 ] as $ length ) {
122138 $ str = $ randomString ($ length );
123- $ protocol ->run ('RETURN $s = " ' . str_replace (['\\' , '" ' ], ['\\\\' , '\\" ' ], $ str ) . '" ' , ['s ' => $ str ], ['mode ' => 'r ' ]);
124- $ res = $ protocol ->pullAll ();
125- $ this ->assertTrue ($ res [0 ][0 ]);
139+ try {
140+ $ protocol ->run ('RETURN $s = " ' . str_replace (['\\' , '" ' ], ['\\\\' , '\\" ' ], $ str ) . '" ' , ['s ' => $ str ], ['mode ' => 'r ' ]);
141+ $ res = $ protocol ->pullAll ();
142+ $ this ->assertTrue ($ res [0 ][0 ]);
143+ } catch (Exception $ e ) {
144+ $ this ->markTestIncomplete ($ e ->getMessage ());
145+ }
126146 }
127147 }
128148
@@ -134,9 +154,13 @@ public function testList(AProtocol $protocol)
134154 {
135155 foreach ([0 , 10 , 200 , 60000 , 200000 ] as $ size ) {
136156 $ arr = $ this ->randomArray ($ size );
137- $ protocol ->run ('RETURN size($arr) = ' . count ($ arr ), ['arr ' => $ arr ], ['mode ' => 'r ' ]);
138- $ res = $ protocol ->pullAll ();
139- $ this ->assertTrue ($ res [0 ][0 ]);
157+ try {
158+ $ protocol ->run ('RETURN size($arr) = ' . count ($ arr ), ['arr ' => $ arr ], ['mode ' => 'r ' ]);
159+ $ res = $ protocol ->pullAll ();
160+ $ this ->assertTrue ($ res [0 ][0 ]);
161+ } catch (Exception $ e ) {
162+ $ this ->markTestIncomplete ($ e ->getMessage ());
163+ }
140164 }
141165 }
142166
@@ -157,9 +181,56 @@ public function testDictionary(AProtocol $protocol)
157181 {
158182 foreach ([0 , 10 , 200 , 60000 , 200000 ] as $ size ) {
159183 $ arr = $ this ->randomArray ($ size );
160- $ protocol ->run ('RETURN size(keys($arr)) = ' . count ($ arr ), ['arr ' => (object )$ arr ], ['mode ' => 'r ' ]);
161- $ res = $ protocol ->pullAll ();
162- $ this ->assertTrue ($ res [0 ][0 ]);
184+ try {
185+ $ protocol ->run ('RETURN size(keys($arr)) = ' . count ($ arr ), ['arr ' => (object )$ arr ], ['mode ' => 'r ' ]);
186+ $ res = $ protocol ->pullAll ();
187+ $ this ->assertTrue ($ res [0 ][0 ]);
188+ } catch (Exception $ e ) {
189+ $ this ->markTestIncomplete ($ e ->getMessage ());
190+ }
191+ }
192+ }
193+
194+ /**
195+ * @depends testInit
196+ * @param AProtocol $protocol
197+ */
198+ public function testListGenerator (AProtocol $ protocol )
199+ {
200+ $ data = [
201+ 'first ' ,
202+ 'second ' ,
203+ 'third '
204+ ];
205+ $ list = new \Bolt \tests \PackStream \v1 \generators \ListGenerator ($ data );
206+ try {
207+ $ protocol ->run ('UNWIND $list AS row RETURN row ' , ['list ' => $ list ]);
208+ $ result = $ protocol ->pullAll ();
209+ foreach ($ data as $ i => $ value )
210+ $ this ->assertEquals ($ value , $ result [$ i ][0 ]);
211+ } catch (Exception $ e ) {
212+ $ this ->markTestIncomplete ($ e ->getMessage ());
213+ }
214+ }
215+
216+ /**
217+ * @depends testInit
218+ * @param AProtocol $protocol
219+ */
220+ public function testDictionaryGenerator (AProtocol $ protocol )
221+ {
222+ $ data = [
223+ 'a ' => 'first ' ,
224+ 'b ' => 'second ' ,
225+ 'c ' => 'third '
226+ ];
227+ $ dict = new \Bolt \tests \PackStream \v1 \generators \DictionaryGenerator ($ data );
228+ try {
229+ $ protocol ->run ('RETURN $dict ' , ['dict ' => $ dict ]);
230+ $ result = $ protocol ->pullAll ();
231+ $ this ->assertEquals ($ data , $ result [0 ][0 ]);
232+ } catch (Exception $ e ) {
233+ $ this ->markTestIncomplete ($ e ->getMessage ());
163234 }
164235 }
165236
0 commit comments