Skip to content

Commit a4da6a4

Browse files
committed
removed apoc.util.sleep methods where applicable
1 parent 72d9fe9 commit a4da6a4

File tree

1 file changed

+22
-12
lines changed

1 file changed

+22
-12
lines changed

tests/Integration/ComplexQueryTest.php

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -357,9 +357,12 @@ public function testLongQueryFunctionNegative(string $alias): void
357357
self::markTestSkipped('Http does not support timeouts at the moment');
358358
}
359359

360-
$this->expectException(ConnectionTimeoutException::class);
360+
$this->expectException(Neo4jException::class);
361361
$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);
363366
}, $alias, TransactionConfiguration::default()->withTimeout(1));
364367
}
365368

@@ -371,9 +374,12 @@ public function testLongQueryUnmanaged(string $alias): void
371374
if (str_starts_with($alias, 'http')) {
372375
self::markTestSkipped('Http does not support timeouts at the moment');
373376
}
374-
$this->expectException(ConnectionTimeoutException::class);
377+
$this->expectException(Neo4jException::class);
375378
$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);
377383
}
378384

379385
/**
@@ -389,7 +395,7 @@ public function testSimpleTimeout(string $alias): void
389395
$this->getClient()
390396
->getDriver($alias)
391397
->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));
393399
} catch (Neo4jException $e) {
394400
self::assertEquals('Neo.ClientError.Transaction.TransactionTimedOut', $e->getNeo4jCode());
395401
}
@@ -409,7 +415,7 @@ public function testDiscardAfterTimeout(string $alias): void
409415
$result = $this->getClient()
410416
->getDriver($alias)
411417
->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));
413419

414420
unset($result);
415421
}
@@ -423,10 +429,11 @@ public function testTimeout(string $alias): void
423429
self::markTestSkipped('Http does not support timeouts at the moment');
424430
}
425431

432+
$tsx = $this->getClient()->beginTransaction([], $alias, TransactionConfiguration::default()->withTimeout(1));
426433
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());
430437
$tsx = $this->getClient()->beginTransaction([], $alias, TransactionConfiguration::default()->withTimeout(20));
431438
self::assertEquals(1, $tsx->run('RETURN 1 AS one')->first()->get('one'));
432439
}
@@ -455,8 +462,11 @@ public function testLongQueryUnmanagedNegative(string $alias): void
455462
self::markTestSkipped('HTTP does not support tsx timeout at the moment.');
456463
}
457464

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+
}
461471
}
462472
}

0 commit comments

Comments
 (0)