19
19
use Laudis \Neo4j \Contracts \FormatterInterface ;
20
20
use Laudis \Neo4j \Contracts \TransactionInterface ;
21
21
use Laudis \Neo4j \Databags \Statement ;
22
+ use Laudis \Neo4j \Databags \SummarizedResult ;
22
23
use Laudis \Neo4j \Exception \Neo4jException ;
23
- use Laudis \Neo4j \Formatter \BasicFormatter ;
24
+ use Laudis \Neo4j \Formatter \SummarizedResultFormatter ;
25
+ use Laudis \Neo4j \Types \CypherMap ;
24
26
25
27
/**
26
- * @psalm-import-type BasicResults from \Laudis\Neo4j\Formatter\BasicFormatter
28
+ * @psalm-import-type OGMTypes from \Laudis\Neo4j\Formatter\OGMFormatter
27
29
*
28
- * @extends EnvironmentAwareIntegrationTest<BasicResults >
30
+ * @extends EnvironmentAwareIntegrationTest<SummarizedResult<CypherMap<OGMTypes>> >
29
31
*/
30
32
final class ClientIntegrationTest extends EnvironmentAwareIntegrationTest
31
33
{
32
- protected function formatter (): FormatterInterface
34
+ protected static function formatter (): FormatterInterface
33
35
{
34
- /** @psalm-suppress InvalidReturnStatement */
35
- return new BasicFormatter ();
36
+ return SummarizedResultFormatter::create ();
36
37
}
37
38
38
39
public function testEqualEffect (): void
@@ -48,8 +49,8 @@ public function testEqualEffect(): void
48
49
$ prev = null ;
49
50
foreach ($ this ->connectionAliases () as $ current ) {
50
51
if ($ prev !== null ) {
51
- $ x = $ this ->client ->runStatement ($ statement , $ prev );
52
- $ y = $ this ->client ->runStatement ($ statement , $ current [0 ]);
52
+ $ x = $ this ->getClient () ->runStatement ($ statement , $ prev );
53
+ $ y = $ this ->getClient () ->runStatement ($ statement , $ current [0 ]);
53
54
54
55
self ::assertEquals ($ x , $ y );
55
56
self ::assertEquals ($ x ->toArray (), $ y ->toArray ());
@@ -63,7 +64,7 @@ public function testEqualEffect(): void
63
64
*/
64
65
public function testAvailabilityFullImplementation (string $ alias ): void
65
66
{
66
- $ results = $ this ->client ->getDriver ($ alias )
67
+ $ results = $ this ->getClient () ->getDriver ($ alias )
67
68
->createSession ()
68
69
->beginTransaction ()
69
70
->run ('UNWIND [1] AS x RETURN x ' )
@@ -78,20 +79,20 @@ public function testAvailabilityFullImplementation(string $alias): void
78
79
*/
79
80
public function testTransactionFunction (string $ alias ): void
80
81
{
81
- $ result = $ this ->client ->transaction (static function (TransactionInterface $ tsx ) {
82
- return $ tsx ->run ('UNWIND [1] AS x RETURN x ' )->first ()->get ('x ' );
82
+ $ result = $ this ->getClient () ->transaction (static function (TransactionInterface $ tsx ) {
83
+ return $ tsx ->run ('UNWIND [1] AS x RETURN x ' )->first ()->getAsInt ('x ' );
83
84
}, $ alias );
84
85
85
86
self ::assertEquals (1 , $ result );
86
87
87
- $ result = $ this ->client ->readTransaction (static function (TransactionInterface $ tsx ) {
88
- return $ tsx ->run ('UNWIND [1] AS x RETURN x ' )->first ()->get ('x ' );
88
+ $ result = $ this ->getClient () ->readTransaction (static function (TransactionInterface $ tsx ) {
89
+ return $ tsx ->run ('UNWIND [1] AS x RETURN x ' )->first ()->getAsInt ('x ' );
89
90
}, $ alias );
90
91
91
92
self ::assertEquals (1 , $ result );
92
93
93
- $ result = $ this ->client ->writeTransaction (static function (TransactionInterface $ tsx ) {
94
- return $ tsx ->run ('UNWIND [1] AS x RETURN x ' )->first ()->get ('x ' );
94
+ $ result = $ this ->getClient () ->writeTransaction (static function (TransactionInterface $ tsx ) {
95
+ return $ tsx ->run ('UNWIND [1] AS x RETURN x ' )->first ()->getAsInt ('x ' );
95
96
}, $ alias );
96
97
97
98
self ::assertEquals (1 , $ result );
@@ -102,7 +103,7 @@ public function testTransactionFunction(string $alias): void
102
103
*/
103
104
public function testValidRun (string $ alias ): void
104
105
{
105
- $ response = $ this ->client ->run (<<<'CYPHER'
106
+ $ response = $ this ->getClient () ->run (<<<'CYPHER'
106
107
MERGE (x:TestNode {test: $test})
107
108
WITH x
108
109
MERGE (y:OtherTestNode {test: $otherTest})
@@ -127,7 +128,7 @@ public function testInvalidRun(string $alias): void
127
128
{
128
129
$ exception = false ;
129
130
try {
130
- $ this ->client ->run ('MERGE (x:Tes0342hdm21.()) ' , ['test ' => 'a ' , 'otherTest ' => 'b ' ], $ alias );
131
+ $ this ->getClient () ->run ('MERGE (x:Tes0342hdm21.()) ' , ['test ' => 'a ' , 'otherTest ' => 'b ' ], $ alias );
131
132
} catch (Neo4jException $ e ) {
132
133
$ exception = true ;
133
134
}
@@ -139,7 +140,7 @@ public function testInvalidRun(string $alias): void
139
140
*/
140
141
public function testValidStatement (string $ alias ): void
141
142
{
142
- $ response = $ this ->client ->runStatement (
143
+ $ response = $ this ->getClient () ->runStatement (
143
144
Statement::create (<<<'CYPHER'
144
145
MERGE (x:TestNode {test: $test})
145
146
WITH x
@@ -168,7 +169,7 @@ public function testInvalidStatement(string $alias): void
168
169
$ exception = false ;
169
170
try {
170
171
$ statement = Statement::create ('MERGE (x:Tes0342hdm21.()) ' , ['test ' => 'a ' , 'otherTest ' => 'b ' ]);
171
- $ this ->client ->runStatement ($ statement , $ alias );
172
+ $ this ->getClient () ->runStatement ($ statement , $ alias );
172
173
} catch (Neo4jException $ e ) {
173
174
$ exception = true ;
174
175
}
@@ -181,7 +182,7 @@ public function testInvalidStatement(string $alias): void
181
182
public function testStatements (string $ alias ): void
182
183
{
183
184
$ params = ['test ' => 'a ' , 'otherTest ' => 'b ' ];
184
- $ response = $ this ->client ->runStatements ([
185
+ $ response = $ this ->getClient () ->runStatements ([
185
186
Statement::create (<<<'CYPHER'
186
187
MERGE (x:TestNode {test: $test})
187
188
CYPHER,
@@ -215,7 +216,7 @@ public function testInvalidStatements(string $alias): void
215
216
{
216
217
$ this ->expectException (Neo4jException::class);
217
218
$ params = ['test ' => 'a ' , 'otherTest ' => 'b ' ];
218
- $ this ->client ->runStatements ([
219
+ $ this ->getClient () ->runStatements ([
219
220
Statement::create (<<<'CYPHER'
220
221
MERGE (x:TestNode {test: $test})
221
222
CYPHER,
@@ -235,8 +236,8 @@ public function testInvalidStatements(string $alias): void
235
236
*/
236
237
public function testMultipleTransactions (string $ alias ): void
237
238
{
238
- $ x = $ this ->client ->beginTransaction (null , $ alias );
239
- $ y = $ this ->client ->beginTransaction (null , $ alias );
239
+ $ x = $ this ->getClient () ->beginTransaction (null , $ alias );
240
+ $ y = $ this ->getClient () ->beginTransaction (null , $ alias );
240
241
self ::assertNotSame ($ x , $ y );
241
242
$ x ->rollback ();
242
243
$ y ->rollback ();
@@ -247,7 +248,7 @@ public function testInvalidConnection(): void
247
248
$ this ->expectException (InvalidArgumentException::class);
248
249
$ this ->expectExceptionMessage ('The provided alias: "ghqkneq;tr" was not found in the client ' );
249
250
250
- $ this ->client ->run ('RETURN 1 AS x ' , [], 'ghqkneq;tr ' );
251
+ $ this ->getClient () ->run ('RETURN 1 AS x ' , [], 'ghqkneq;tr ' );
251
252
}
252
253
253
254
public function testInvalidConnectionCheck (): void
@@ -268,6 +269,6 @@ public function testInvalidConnectionCheck(): void
268
269
*/
269
270
public function testValidConnectionCheck (string $ alias ): void
270
271
{
271
- self ::assertTrue ($ this ->client ->verifyConnectivity ($ alias ));
272
+ self ::assertTrue ($ this ->getClient () ->verifyConnectivity ($ alias ));
272
273
}
273
274
}
0 commit comments