33namespace Bolt \tests ;
44
55use Bolt \Bolt ;
6+ use Exception ;
67
78/**
89 * Class BoltTest
1112 * @link https://github.com/stefanak-michal/Bolt
1213 *
1314 * @covers \Bolt\Bolt
15+ * @covers \Bolt\connection\AConnection
1416 * @covers \Bolt\connection\Socket
1517 * @covers \Bolt\connection\StreamSocket
1618 * @covers \Bolt\PackStream\v1\Packer
2123 * @requires extension sockets
2224 * @requires extension mbstring
2325 */
24- class BoltTest extends \ Bolt \ tests \ ATest
26+ class BoltTest extends ATest
2527{
2628
2729 /**
@@ -46,7 +48,7 @@ public function testHello(): ?Bolt
4648 $ this ->assertTrue ($ bolt ->hello ('Test/1.0 ' , $ GLOBALS ['NEO_USER ' ], $ GLOBALS ['NEO_PASS ' ]));
4749
4850 return $ bolt ;
49- } catch (\ Exception $ e ) {
51+ } catch (Exception $ e ) {
5052 $ this ->markTestSkipped ($ e ->getMessage ());
5153 }
5254
@@ -59,13 +61,17 @@ public function testHello(): ?Bolt
5961 */
6062 public function testPull (Bolt $ bolt )
6163 {
62- $ res = $ bolt ->run ('RETURN 1 AS num, 2 AS cnt ' );
63- $ this ->assertIsArray ($ res );
64- $ this ->assertArrayHasKey ('fields ' , $ res );
65-
66- $ res = $ bolt ->pull ();
67- $ this ->assertEquals (1 , $ res [0 ][0 ] ?? 0 );
68- $ this ->assertEquals (2 , $ res [0 ][1 ] ?? 0 );
64+ try {
65+ $ res = $ bolt ->run ('RETURN 1 AS num, 2 AS cnt ' );
66+ $ this ->assertIsArray ($ res );
67+ $ this ->assertArrayHasKey ('fields ' , $ res );
68+
69+ $ res = $ bolt ->pull ();
70+ $ this ->assertEquals (1 , $ res [0 ][0 ] ?? 0 );
71+ $ this ->assertEquals (2 , $ res [0 ][1 ] ?? 0 );
72+ } catch (Exception $ e ) {
73+ $ this ->markTestSkipped ($ e ->getMessage ());
74+ }
6975 }
7076
7177 /**
@@ -74,8 +80,12 @@ public function testPull(Bolt $bolt)
7480 */
7581 public function testDiscard (Bolt $ bolt )
7682 {
77- $ this ->assertNotFalse ($ bolt ->run ('MATCH (a:Test) RETURN * ' ));
78- $ this ->assertTrue ($ bolt ->discard ());
83+ try {
84+ $ this ->assertNotFalse ($ bolt ->run ('MATCH (a:Test) RETURN * ' ));
85+ $ this ->assertTrue ($ bolt ->discard ());
86+ } catch (Exception $ e ) {
87+ $ this ->markTestSkipped ($ e ->getMessage ());
88+ }
7989 }
8090
8191 /**
@@ -84,16 +94,20 @@ public function testDiscard(Bolt $bolt)
8494 */
8595 public function testNode (Bolt $ bolt )
8696 {
87- $ this ->assertNotFalse ($ bolt ->run ('CREATE (a:Test) RETURN a, ID(a) ' ));
97+ try {
98+ $ this ->assertNotFalse ($ bolt ->run ('CREATE (a:Test) RETURN a, ID(a) ' ));
8899
89- $ created = $ bolt ->pull ();
90- $ this ->assertIsArray ($ created );
91- $ this ->assertInstanceOf (\Bolt \structures \Node::class, $ created [0 ][0 ]);
100+ $ created = $ bolt ->pull ();
101+ $ this ->assertIsArray ($ created );
102+ $ this ->assertInstanceOf (\Bolt \structures \Node::class, $ created [0 ][0 ]);
92103
93- $ this ->assertNotFalse ($ bolt ->run ('MATCH (a:Test) WHERE ID(a) = ' . $ this ->formatParameter ($ bolt , 'a ' ) . ' DELETE a ' , [
94- 'a ' => $ created [0 ][1 ]
95- ]));
96- $ this ->assertEquals (1 , $ bolt ->pull ()[0 ]['stats ' ]['nodes-deleted ' ] ?? 0 );
104+ $ this ->assertNotFalse ($ bolt ->run ('MATCH (a:Test) WHERE ID(a) = ' . $ this ->formatParameter ($ bolt , 'a ' ) . ' DELETE a ' , [
105+ 'a ' => $ created [0 ][1 ]
106+ ]));
107+ $ this ->assertEquals (1 , $ bolt ->pull ()[0 ]['stats ' ]['nodes-deleted ' ] ?? 0 );
108+ } catch (Exception $ e ) {
109+ $ this ->markTestSkipped ($ e ->getMessage ());
110+ }
97111 }
98112
99113 /**
@@ -107,18 +121,22 @@ public function testTransaction(Bolt $bolt)
107121 return ;
108122 }
109123
110- $ this ->assertTrue ($ bolt ->begin ());
111- $ this ->assertNotFalse ($ bolt ->run ('CREATE (a:Test) RETURN a, ID(a) ' ));
112- $ created = $ bolt ->pull ();
113- $ this ->assertIsArray ($ created );
114- $ this ->assertTrue ($ bolt ->rollback ());
115-
116- $ this ->assertNotFalse ($ bolt ->run ('MATCH (a:Test) WHERE ID(a) = ' . $ this ->formatParameter ($ bolt , 'a ' ) . ' RETURN COUNT(a) ' , [
117- 'a ' => $ created [0 ][1 ]
118- ]));
119- $ res = $ bolt ->pull ();
120- $ this ->assertIsArray ($ res );
121- $ this ->assertEquals (0 , $ res [0 ][0 ]);
124+ try {
125+ $ this ->assertTrue ($ bolt ->begin ());
126+ $ this ->assertNotFalse ($ bolt ->run ('CREATE (a:Test) RETURN a, ID(a) ' ));
127+ $ created = $ bolt ->pull ();
128+ $ this ->assertIsArray ($ created );
129+ $ this ->assertTrue ($ bolt ->rollback ());
130+
131+ $ this ->assertNotFalse ($ bolt ->run ('MATCH (a:Test) WHERE ID(a) = ' . $ this ->formatParameter ($ bolt , 'a ' ) . ' RETURN COUNT(a) ' , [
132+ 'a ' => $ created [0 ][1 ]
133+ ]));
134+ $ res = $ bolt ->pull ();
135+ $ this ->assertIsArray ($ res );
136+ $ this ->assertEquals (0 , $ res [0 ][0 ]);
137+ } catch (Exception $ e ) {
138+ $ this ->markTestSkipped ($ e ->getMessage ());
139+ }
122140 }
123141
124142 /**
@@ -131,6 +149,7 @@ public function testTransaction(Bolt $bolt)
131149 * @param Bolt $bolt
132150 * @param string $name
133151 * @return string
152+ * @throws Exception
134153 */
135154 private function formatParameter (Bolt $ bolt , string $ name ): string
136155 {
0 commit comments