3636class BoltTest extends ATest
3737{
3838
39- private static $ version ;
40-
4139 public function testSockets ()
4240 {
4341 if (!extension_loaded ('sockets ' ))
@@ -85,7 +83,6 @@ public function testHello(): AProtocol
8583
8684 $ this ->assertNotEmpty ($ protocol ->init (\Bolt \helpers \Auth::basic ($ GLOBALS ['NEO_USER ' ], $ GLOBALS ['NEO_PASS ' ])));
8785
88- self ::$ version = $ bolt ->getProtocolVersion ();
8986 return $ protocol ;
9087 } catch (Exception $ e ) {
9188 $ this ->markTestIncomplete ($ e ->getMessage ());
@@ -94,16 +91,16 @@ public function testHello(): AProtocol
9491
9592 /**
9693 * @depends testHello
97- * @param AProtocol $bolt
94+ * @param AProtocol $protocol
9895 */
99- public function testPull (AProtocol $ bolt )
96+ public function testPull (AProtocol $ protocol )
10097 {
10198 try {
102- $ res = $ bolt ->run ('RETURN 1 AS num, 2 AS cnt ' );
99+ $ res = $ protocol ->run ('RETURN 1 AS num, 2 AS cnt ' );
103100 $ this ->assertIsArray ($ res );
104101 $ this ->assertArrayHasKey ('fields ' , $ res );
105102
106- $ res = $ bolt ->pullAll ();
103+ $ res = $ protocol ->pullAll ();
107104 $ this ->assertEquals (1 , $ res [0 ][0 ] ?? 0 );
108105 $ this ->assertEquals (2 , $ res [0 ][1 ] ?? 0 );
109106 } catch (Exception $ e ) {
@@ -113,61 +110,62 @@ public function testPull(AProtocol $bolt)
113110
114111 /**
115112 * @depends testHello
116- * @param AProtocol $bolt
113+ * @param AProtocol $protocol
117114 */
118- public function testDiscard (AProtocol $ bolt )
115+ public function testDiscard (AProtocol $ protocol )
119116 {
120117 try {
121- $ this ->assertNotFalse ($ bolt ->run ('MATCH (a:Test) RETURN * ' ));
122- $ this ->assertIsArray ($ bolt ->discardAll ());
118+ $ this ->assertNotFalse ($ protocol ->run ('MATCH (a:Test) RETURN * ' ));
119+ $ this ->assertIsArray ($ protocol ->discardAll ());
123120 } catch (Exception $ e ) {
124121 $ this ->markTestIncomplete ($ e ->getMessage ());
125122 }
126123 }
127124
128125 /**
129126 * @depends testHello
130- * @param AProtocol $bolt
127+ * @param AProtocol $protocol
131128 */
132- public function testNode (AProtocol $ bolt )
129+ public function testNode (AProtocol $ protocol )
133130 {
134131 try {
135- $ this ->assertNotFalse ($ bolt ->run ('CREATE (a:Test) RETURN a, ID(a) ' ));
132+ $ this ->assertNotFalse ($ protocol ->run ('CREATE (a:Test) RETURN a, ID(a) ' ));
136133
137- $ created = $ bolt ->pullAll ();
134+ $ created = $ protocol ->pullAll ();
138135 $ this ->assertIsArray ($ created );
139136 $ this ->assertInstanceOf (\Bolt \structures \Node::class, $ created [0 ][0 ]);
140137
141- $ this ->assertNotFalse ($ bolt ->run ('MATCH (a:Test) WHERE ID(a) = ' . $ this ->formatParameter ($ bolt , 'a ' ) . ' DELETE a ' , [
138+ $ this ->assertNotFalse ($ protocol ->run ('MATCH (a:Test) WHERE ID(a) = ' . $ this ->formatParameter ($ protocol , 'a ' ) . ' DELETE a ' , [
142139 'a ' => $ created [0 ][1 ]
143140 ]));
144- $ this ->assertEquals (1 , $ bolt ->pullAll ()[0 ]['stats ' ]['nodes-deleted ' ] ?? 0 );
141+ $ this ->assertEquals (1 , $ protocol ->pullAll ()[0 ]['stats ' ]['nodes-deleted ' ] ?? 0 );
145142 } catch (Exception $ e ) {
146143 $ this ->markTestIncomplete ($ e ->getMessage ());
147144 }
148145 }
149146
150147 /**
151148 * @depends testHello
152- * @param AProtocol $bolt
149+ * @param AProtocol $protocol
150+ * @throws Exception
153151 */
154- public function testTransaction (AProtocol $ bolt )
152+ public function testTransaction (AProtocol $ protocol )
155153 {
156- if (self :: $ version < 3 ) {
154+ if (version_compare ( $ protocol -> getVersion (), 3 , ' < ' ) ) {
157155 $ this ->markTestSkipped ('Old Neo4j version does not support transactions ' );
158156 }
159157
160158 try {
161- $ this ->assertIsArray ($ bolt ->begin ());
162- $ this ->assertIsArray ($ bolt ->run ('CREATE (a:Test) RETURN a, ID(a) ' ));
163- $ created = $ bolt ->pullAll ();
159+ $ this ->assertIsArray ($ protocol ->begin ());
160+ $ this ->assertIsArray ($ protocol ->run ('CREATE (a:Test) RETURN a, ID(a) ' ));
161+ $ created = $ protocol ->pullAll ();
164162 $ this ->assertIsArray ($ created );
165- $ this ->assertIsArray ($ bolt ->rollback ());
163+ $ this ->assertIsArray ($ protocol ->rollback ());
166164
167- $ this ->assertIsArray ($ bolt ->run ('MATCH (a:Test) WHERE ID(a) = ' . $ this ->formatParameter ($ bolt , 'a ' ) . ' RETURN COUNT(a) ' , [
165+ $ this ->assertIsArray ($ protocol ->run ('MATCH (a:Test) WHERE ID(a) = ' . $ this ->formatParameter ($ protocol , 'a ' ) . ' RETURN COUNT(a) ' , [
168166 'a ' => $ created [0 ][1 ]
169167 ]));
170- $ res = $ bolt ->pullAll ();
168+ $ res = $ protocol ->pullAll ();
171169 $ this ->assertIsArray ($ res );
172170 $ this ->assertEquals (0 , $ res [0 ][0 ]);
173171 } catch (Exception $ e ) {
@@ -182,16 +180,16 @@ public function testTransaction(AProtocol $bolt)
182180
183181 /**
184182 * Because from Neo4j >= 4.0 is different placeholder for parameters
185- * @param AProtocol $bolt
183+ * @param AProtocol $protocol
186184 * @param string $name
187185 * @return string
188186 * @throws Exception
189187 */
190- private function formatParameter (AProtocol $ bolt , string $ name ): string
188+ private function formatParameter (AProtocol $ protocol , string $ name ): string
191189 {
192190 if (self ::$ parameterType == null ) {
193- $ this ->assertNotFalse ($ bolt ->run ('call dbms.components() yield versions unwind versions as version return version ' ));
194- $ neo4jVersion = $ bolt ->pullAll ()[0 ][0 ] ?? '' ;
191+ $ this ->assertNotFalse ($ protocol ->run ('call dbms.components() yield versions unwind versions as version return version ' ));
192+ $ neo4jVersion = $ protocol ->pullAll ()[0 ][0 ] ?? '' ;
195193 $ this ->assertNotEmpty ($ neo4jVersion );
196194 self ::$ parameterType = version_compare ($ neo4jVersion , '4 ' ) == -1 ;
197195 }
@@ -201,12 +199,13 @@ private function formatParameter(AProtocol $bolt, string $name): string
201199
202200 /**
203201 * @depends testHello
204- * @param AProtocol $bolt
202+ * @param AProtocol $protocol
203+ * @throws Exception
205204 */
206- public function testRoute (AProtocol $ bolt ): void
205+ public function testRoute (AProtocol $ protocol ): void
207206 {
208- if (self :: $ version >= 4.3 ) {
209- self ::assertIsArray ($ bolt ->route ([
207+ if (version_compare ( $ protocol -> getVersion (), 4.3 , ' >= ' ) ) {
208+ self ::assertIsArray ($ protocol ->route ([
210209 'address ' => ($ GLOBALS ['NEO_HOST ' ] ?? '127.0.0.1 ' ) . ': ' . ($ GLOBALS ['NEO_PORT ' ] ?? 7687 )
211210 ], [], []));
212211 } else {
@@ -216,12 +215,12 @@ public function testRoute(AProtocol $bolt): void
216215
217216 /**
218217 * @depends testHello
219- * @param AProtocol $bolt
218+ * @param AProtocol $protocol
220219 */
221- public function testReset (AProtocol $ bolt ): void
220+ public function testReset (AProtocol $ protocol ): void
222221 {
223222 try {
224- $ this ->assertIsArray ($ bolt ->reset ());
223+ $ this ->assertIsArray ($ protocol ->reset ());
225224 } catch (Exception $ e ) {
226225 $ this ->markTestIncomplete ($ e ->getMessage ());
227226 }
0 commit comments