7
7
8
8
use Laudis \Neo4j \ClientBuilder ;
9
9
use Laudis \Neo4j \Contracts \ClientInterface ;
10
+ use Laudis \Neo4j \Databags \Statement ;
11
+ use Laudis \Neo4j \Network \Bolt \BoltInjections ;
10
12
use PHPUnit \Framework \TestCase ;
11
13
12
14
final class HttpConsistencyTest extends TestCase
@@ -17,19 +19,52 @@ protected function setUp(): void
17
19
{
18
20
parent ::setUp ();
19
21
$ this ->client = ClientBuilder::create ()
20
- ->addHttpConnection ('default ' , 'http://neo4j:test@neo4j ' )
21
- ->setDefaultConnection ('default ' )
22
+ ->addHttpConnection ('http ' , 'http://neo4j:test@neo4j ' )
23
+ ->addBoltConnection ('bolt ' , 'bolt://neo4j:test@neo4j ' )
24
+ ->addBoltConnection ('neo4j ' , 'bolt://neo4j:test@neo4j ' , BoltInjections::create ()->withAutoRouting (true ))
22
25
->build ();
26
+
27
+ $ this ->client ->run ('MATCH (x) DETACH DELETE x ' );
23
28
}
24
29
25
- public function testConsistency (): void
30
+ /**
31
+ * @dataProvider aliases
32
+ */
33
+ public function testConsistency (string $ alias ): void
26
34
{
27
- $ res = $ this ->client ->run ('MERGE (n:zzz {name: "bbbb"}) RETURN n ' );
35
+ $ res = $ this ->client ->run ('MERGE (n:zzz {name: "bbbb"}) RETURN n ' , [], $ alias );
28
36
self ::assertEquals (1 , $ res ->count ());
29
37
self ::assertEquals (['name ' => 'bbbb ' ], $ res ->first ()->get ('n ' ));
30
38
31
- $ res = $ this ->client ->run ('MATCH (n:zzz {name: $name}) RETURN n ' , ['name ' => 'bbbb ' ]);
39
+ $ res = $ this ->client ->run ('MATCH (n:zzz {name: $name}) RETURN n ' , ['name ' => 'bbbb ' ], $ alias );
32
40
self ::assertEquals (1 , $ res ->count ());
33
41
self ::assertEquals (['name ' => 'bbbb ' ], $ res ->first ()->get ('n ' ));
34
42
}
43
+
44
+ /**
45
+ * @dataProvider aliases
46
+ */
47
+ public function testConsistencyTransaction (string $ alias ): void
48
+ {
49
+ $ tsx = $ this ->client ->openTransaction ([
50
+ Statement::create ('CREATE (n:aaa) SET n.name="aaa" return n ' )
51
+ ], $ alias );
52
+
53
+ $ tsx ->commit ([Statement::create ('CREATE (n:bbb) SET n.name="bbb" return n ' )]);
54
+
55
+ $ results = $ this ->client ->run ('MATCH (n) RETURN n ' , ['name ' => 'bbbb ' ], $ alias );
56
+
57
+ self ::assertEquals (2 , $ results ->count ());
58
+ self ::assertEquals (['name ' => 'aaa ' ], $ results ->first ()->get ('n ' ));
59
+ self ::assertEquals (['name ' => 'bbb ' ], $ results ->last ()->get ('n ' ));
60
+ }
61
+
62
+ public function aliases (): array
63
+ {
64
+ return [
65
+ ['http ' ],
66
+ ['bolt ' ],
67
+ ['neo4j ' ]
68
+ ];
69
+ }
35
70
}
0 commit comments