Skip to content

Commit e154ddb

Browse files
committed
Added more positive and negative tests for transaction timouts
references #64
1 parent ba5eafb commit e154ddb

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

tests/Integration/ComplexQueryTests.php

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
namespace Laudis\Neo4j\Tests\Integration;
1515

16+
use Bolt\error\ConnectException;
1617
use Generator;
1718
use function getenv;
1819
use InvalidArgumentException;
@@ -270,11 +271,50 @@ public function testPeriodicCommitFail(string $alias): void
270271
/**
271272
* @dataProvider connectionAliases
272273
*/
273-
public function testLongQuery(string $alias): void
274+
public function testLongQueryFunction(string $alias): void
274275
{
275276
$this->client->writeTransaction(static function (TransactionInterface $tsx) {
276277
$tsx->run('UNWIND range(1, 10000) AS x MERGE (:Number {value: x})');
277278
}, $alias, TransactionConfiguration::default()->withTimeout(100000));
278279
self::assertTrue(true);
279280
}
281+
282+
/**
283+
* @dataProvider connectionAliases
284+
*/
285+
public function testLongQueryFunctionNegative(string $alias): void
286+
{
287+
if (str_starts_with($alias, 'http')) {
288+
self::markTestSkipped('HTTP does not support tsx timeout at the moment.');
289+
}
290+
291+
$this->expectException(ConnectException::class);
292+
$this->client->writeTransaction(static function (TransactionInterface $tsx) {
293+
$tsx->run('UNWIND range(1, 10000) AS x MERGE (:Number {value: x})');
294+
}, $alias, TransactionConfiguration::default()->withTimeout(1));
295+
}
296+
297+
/**
298+
* @dataProvider connectionAliases
299+
*/
300+
public function testLongQueryUnmanaged(string $alias): void
301+
{
302+
$tsx = $this->client->beginTransaction([], $alias, TransactionConfiguration::default()->withTimeout(100000));
303+
$tsx->run('UNWIND range(1, 10000) AS x MERGE (:Number {value: x})');
304+
self::assertTrue(true);
305+
}
306+
307+
/**
308+
* @dataProvider connectionAliases
309+
*/
310+
public function testLongQueryUnmanagedNegative(string $alias): void
311+
{
312+
if (str_starts_with($alias, 'http')) {
313+
self::markTestSkipped('HTTP does not support tsx timeout at the moment.');
314+
}
315+
316+
$this->expectException(ConnectException::class);
317+
$tsx = $this->client->beginTransaction([], $alias, TransactionConfiguration::default()->withTimeout(1));
318+
$tsx->run('UNWIND range(1, 10000) AS x MERGE (:Number {value: x})');
319+
}
280320
}

0 commit comments

Comments
 (0)