@@ -357,9 +357,12 @@ public function testLongQueryFunctionNegative(string $alias): void
357
357
self ::markTestSkipped ('Http does not support timeouts at the moment ' );
358
358
}
359
359
360
- $ this ->expectException (ConnectionTimeoutException ::class);
360
+ $ this ->expectException (Neo4jException ::class);
361
361
$ this ->getClient ()->writeTransaction (static function (TransactionInterface $ tsx ) {
362
- $ tsx ->run ('CALL apoc.util.sleep(10000) ' );
362
+ $ tsx ->run (<<<'CYPHER'
363
+ UNWIND range(1, 10000) AS id
364
+ MERGE (x:Node {id: id})
365
+ CYPHER);
363
366
}, $ alias , TransactionConfiguration::default ()->withTimeout (1 ));
364
367
}
365
368
@@ -371,9 +374,12 @@ public function testLongQueryUnmanaged(string $alias): void
371
374
if (str_starts_with ($ alias , 'http ' )) {
372
375
self ::markTestSkipped ('Http does not support timeouts at the moment ' );
373
376
}
374
- $ this ->expectException (ConnectionTimeoutException ::class);
377
+ $ this ->expectException (Neo4jException ::class);
375
378
$ tsx = $ this ->getClient ()->beginTransaction ([], $ alias , TransactionConfiguration::default ()->withTimeout (1 ));
376
- $ tsx ->run ('CALL apoc.util.sleep(10000) ' );
379
+ $ tsx ->run (<<<'CYPHER'
380
+ UNWIND range(1, 10000) AS id
381
+ MERGE (x:Node {id: id})
382
+ CYPHER);
377
383
}
378
384
379
385
/**
@@ -389,7 +395,7 @@ public function testSimpleTimeout(string $alias): void
389
395
$ this ->getClient ()
390
396
->getDriver ($ alias )
391
397
->createSession ()
392
- ->run ('CALL apoc.util.sleep(2000000 ) ' , [], TransactionConfiguration::default ()->withTimeout (10 ));
398
+ ->run ('UNWIND range(1, 1000000) AS x MERGE (:Number {value: x} ) ' , [], TransactionConfiguration::default ()->withTimeout (10 ));
393
399
} catch (Neo4jException $ e ) {
394
400
self ::assertEquals ('Neo.ClientError.Transaction.TransactionTimedOut ' , $ e ->getNeo4jCode ());
395
401
}
@@ -409,7 +415,7 @@ public function testDiscardAfterTimeout(string $alias): void
409
415
$ result = $ this ->getClient ()
410
416
->getDriver ($ alias )
411
417
->createSession ()
412
- ->run (" CALL apoc.util.sleep(2000000) " , [], TransactionConfiguration::default ()->withTimeout (150 ));
418
+ ->run (' UNWIND range(1, 1000000) AS x MERGE (:Number {value: x}) ' , [], TransactionConfiguration::default ()->withTimeout (150 ));
413
419
414
420
unset($ result );
415
421
}
@@ -423,10 +429,11 @@ public function testTimeout(string $alias): void
423
429
self ::markTestSkipped ('Http does not support timeouts at the moment ' );
424
430
}
425
431
432
+ $ tsx = $ this ->getClient ()->beginTransaction ([], $ alias , TransactionConfiguration::default ()->withTimeout (1 ));
426
433
try {
427
- $ tsx = $ this -> getClient ()-> beginTransaction ([], $ alias , TransactionConfiguration:: default ()-> withTimeout ( 1 ) );
428
- $ tsx -> run ( ' CALL apoc.util.sleep(10000) ' );
429
- } catch ( ConnectionTimeoutException $ e) {
434
+ $ tsx-> run ( ' UNWIND range(1, 10000) AS x MERGE (:Number {value: x}) ' );
435
+ } catch ( Neo4jException $ e ) {
436
+ self :: assertEquals ( ' Neo.ClientError.Transaction.TransactionTimedOut ' , $ e-> getNeo4jCode ());
430
437
$ tsx = $ this ->getClient ()->beginTransaction ([], $ alias , TransactionConfiguration::default ()->withTimeout (20 ));
431
438
self ::assertEquals (1 , $ tsx ->run ('RETURN 1 AS one ' )->first ()->get ('one ' ));
432
439
}
@@ -455,8 +462,11 @@ public function testLongQueryUnmanagedNegative(string $alias): void
455
462
self ::markTestSkipped ('HTTP does not support tsx timeout at the moment. ' );
456
463
}
457
464
458
- $ this ->expectException (MessageException::class);
459
- $ tsx = $ this ->getClient ()->beginTransaction ([], $ alias , TransactionConfiguration::default ()->withTimeout (1 ));
460
- $ tsx ->run ('UNWIND range(1, 10000) AS x MERGE (:Number {value: x}) ' );
465
+ try {
466
+ $ tsx = $ this ->getClient ()->beginTransaction ([], $ alias , TransactionConfiguration::default ()->withTimeout (1 ));
467
+ $ tsx ->run ('UNWIND range(1, 10000) AS x MERGE (:Number {value: x}) ' );
468
+ } catch (Neo4jException $ e ) {
469
+ self ::assertEquals ('Neo.ClientError.Transaction.TransactionTimedOut ' , $ e ->getNeo4jCode ());
470
+ }
461
471
}
462
472
}
0 commit comments