@@ -43,7 +43,13 @@ public function testValidRun(string $alias): void
43
43
self ::markTestSkipped ('Cannot guarantee successful test in cluster ' );
44
44
}
45
45
46
- $ response = $ this ->getClient ()->beginTransaction (null , $ alias )->run (<<<'CYPHER'
46
+ $ tsx = $ this ->getClient ()->beginTransaction (null , $ alias );
47
+
48
+ self ::assertFalse ($ tsx ->isFinished ());
49
+ self ::assertFalse ($ tsx ->isRolledBack ());
50
+ self ::assertFalse ($ tsx ->isCommitted ());
51
+
52
+ $ response = $ tsx ->run (<<<'CYPHER'
47
53
MERGE (x:TestNode {test: $test})
48
54
WITH x
49
55
MERGE (y:OtherTestNode {test: $otherTest})
@@ -59,6 +65,10 @@ public function testValidRun(string $alias): void
59
65
self ::assertEquals ('a ' , $ map ->get ('test ' ));
60
66
self ::assertEquals (['c ' => 'd ' ], $ map ->get ('map ' ));
61
67
self ::assertEquals ([1 , 2 , 3 ], $ map ->get ('list ' ));
68
+
69
+ self ::assertFalse ($ tsx ->isFinished ());
70
+ self ::assertFalse ($ tsx ->isRolledBack ());
71
+ self ::assertFalse ($ tsx ->isCommitted ());
62
72
}
63
73
64
74
/**
@@ -70,15 +80,23 @@ public function testInvalidRun(string $alias): void
70
80
self ::markTestSkipped ('Cannot guarantee successful test in cluster ' );
71
81
}
72
82
73
- $ transaction = $ this ->getClient ()->beginTransaction (null , $ alias );
83
+ $ tsx = $ this ->getClient ()->beginTransaction (null , $ alias );
84
+
85
+ self ::assertFalse ($ tsx ->isFinished ());
86
+ self ::assertFalse ($ tsx ->isRolledBack ());
87
+ self ::assertFalse ($ tsx ->isCommitted ());
88
+
74
89
$ exception = false ;
75
90
try {
76
- $ transaction ->run ('MERGE (x:Tes0342hdm21.()) ' , ['test ' => 'a ' , 'otherTest ' => 'b ' ]);
91
+ $ tsx ->run ('MERGE (x:Tes0342hdm21.()) ' , ['test ' => 'a ' , 'otherTest ' => 'b ' ]);
77
92
} catch (Neo4jException $ e ) {
78
93
$ exception = true ;
79
94
self ::assertEquals ('Neo.ClientError.Statement.SyntaxError ' , $ e ->getNeo4jCode ());
80
95
}
81
96
self ::assertTrue ($ exception );
97
+ self ::assertTrue ($ tsx ->isFinished ());
98
+ self ::assertTrue ($ tsx ->isRolledBack ());
99
+ self ::assertFalse ($ tsx ->isCommitted ());
82
100
}
83
101
84
102
/**
@@ -175,11 +193,16 @@ public function testInvalidStatements(string $alias): void
175
193
self ::markTestSkipped ('Cannot guarantee successful test in cluster ' );
176
194
}
177
195
178
- $ transaction = $ this ->getClient ()->beginTransaction (null , $ alias );
196
+ $ tsx = $ this ->getClient ()->beginTransaction (null , $ alias );
197
+
198
+ self ::assertFalse ($ tsx ->isFinished ());
199
+ self ::assertFalse ($ tsx ->isRolledBack ());
200
+ self ::assertFalse ($ tsx ->isCommitted ());
201
+
179
202
$ exception = false ;
180
203
try {
181
204
$ params = ['test ' => 'a ' , 'otherTest ' => 'b ' ];
182
- $ transaction ->runStatements ([
205
+ $ tsx ->runStatements ([
183
206
Statement::create (<<<'CYPHER'
184
207
MERGE (x:TestNode {test: $test})
185
208
CYPHER,
@@ -196,6 +219,10 @@ public function testInvalidStatements(string $alias): void
196
219
$ exception = true ;
197
220
}
198
221
self ::assertTrue ($ exception );
222
+
223
+ self ::assertTrue ($ tsx ->isFinished ());
224
+ self ::assertTrue ($ tsx ->isRolledBack ());
225
+ self ::assertFalse ($ tsx ->isCommitted ());
199
226
}
200
227
201
228
/**
@@ -207,8 +234,18 @@ public function testCommitValidEmpty(string $alias): void
207
234
self ::markTestSkipped ('Cannot guarantee successful test in cluster ' );
208
235
}
209
236
210
- $ result = $ this ->getClient ()->beginTransaction (null , $ alias )->commit ();
237
+ $ tsx = $ this ->getClient ()->beginTransaction (null , $ alias );
238
+
239
+ self ::assertFalse ($ tsx ->isFinished ());
240
+ self ::assertFalse ($ tsx ->isRolledBack ());
241
+ self ::assertFalse ($ tsx ->isCommitted ());
242
+
243
+ $ result = $ tsx ->commit ();
211
244
self ::assertEquals (0 , $ result ->count ());
245
+
246
+ self ::assertTrue ($ tsx ->isFinished ());
247
+ self ::assertFalse ($ tsx ->isRolledBack ());
248
+ self ::assertTrue ($ tsx ->isCommitted ());
212
249
}
213
250
214
251
/**
@@ -238,10 +275,18 @@ public function testCommitValidFilledWithInvalidStatement(string $alias): void
238
275
self ::markTestSkipped ('Cannot guarantee successful test in cluster ' );
239
276
}
240
277
241
- $ transaction = $ this ->getClient ()->beginTransaction (null , $ alias );
278
+ $ tsx = $ this ->getClient ()->beginTransaction (null , $ alias );
242
279
243
- $ this ->expectException (Neo4jException::class);
244
- $ transaction ->commit ([Statement::create ('adkjbehqjk ' )]);
280
+ $ exception = false ;
281
+ try {
282
+ $ tsx ->commit ([Statement::create ('adkjbehqjk ' )]);
283
+ } catch (Neo4jException $ e ) {
284
+ $ exception = true ;
285
+ }
286
+ self ::assertTrue ($ exception );
287
+ self ::assertTrue ($ tsx ->isFinished ());
288
+ self ::assertTrue ($ tsx ->isRolledBack ());
289
+ self ::assertFalse ($ tsx ->isCommitted ());
245
290
}
246
291
247
292
/**
@@ -253,11 +298,25 @@ public function testCommitInvalid(string $alias): void
253
298
self ::markTestSkipped ('Cannot guarantee successful test in cluster ' );
254
299
}
255
300
256
- $ transaction = $ this ->getClient ()->beginTransaction (null , $ alias );
257
- $ transaction ->commit ();
301
+ $ tsx = $ this ->getClient ()->beginTransaction (null , $ alias );
302
+ $ tsx ->commit ();
303
+
304
+ self ::assertTrue ($ tsx ->isFinished ());
305
+ self ::assertFalse ($ tsx ->isRolledBack ());
306
+ self ::assertTrue ($ tsx ->isCommitted ());
258
307
259
308
$ this ->expectException (Neo4jException::class);
260
- $ transaction ->commit ();
309
+ $ exception = false ;
310
+ try {
311
+ $ tsx ->commit ();
312
+ } catch (Neo4jException $ e ) {
313
+ $ exception = true ;
314
+ }
315
+ self ::assertTrue ($ exception );
316
+
317
+ self ::assertTrue ($ tsx ->isFinished ());
318
+ self ::assertFalse ($ tsx ->isRolledBack ());
319
+ self ::assertTrue ($ tsx ->isCommitted ());
261
320
}
262
321
263
322
/**
@@ -269,9 +328,12 @@ public function testRollbackValid(string $alias): void
269
328
self ::markTestSkipped ('Cannot guarantee successful test in cluster ' );
270
329
}
271
330
272
- $ transaction = $ this ->getClient ()->beginTransaction (null , $ alias );
273
- $ transaction ->rollback ();
274
- self ::assertTrue (true );
331
+ $ tsx = $ this ->getClient ()->beginTransaction (null , $ alias );
332
+ $ tsx ->rollback ();
333
+
334
+ self ::assertTrue ($ tsx ->isFinished ());
335
+ self ::assertTrue ($ tsx ->isRolledBack ());
336
+ self ::assertFalse ($ tsx ->isCommitted ());
275
337
}
276
338
277
339
/**
@@ -286,8 +348,21 @@ public function testRollbackInvalid(string $alias): void
286
348
$ transaction = $ this ->getClient ()->beginTransaction (null , $ alias );
287
349
$ transaction ->rollback ();
288
350
289
- $ this ->expectException (Neo4jException::class);
290
- $ transaction ->rollback ();
351
+ self ::assertTrue ($ tsx ->isFinished ());
352
+ self ::assertTrue ($ tsx ->isRolledBack ());
353
+ self ::assertFalse ($ tsx ->isCommitted ());
354
+
355
+ $ exception = false ;
356
+ try {
357
+ $ transaction ->rollback ();
358
+ } catch (Neo4jException $ e ) {
359
+ $ exception = true ;
360
+ }
361
+ self ::assertTrue ($ exception );
362
+
363
+ self ::assertTrue ($ tsx ->isFinished ());
364
+ self ::assertTrue ($ tsx ->isRolledBack ());
365
+ self ::assertFalse ($ tsx ->isCommitted ());
291
366
}
292
367
293
368
/**
0 commit comments