Skip to content

Commit 58028d3

Browse files
committed
added test for constraints
1 parent c2c0a36 commit 58028d3

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/Integration/ComplexQueryTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313

1414
namespace Laudis\Neo4j\Tests\Integration;
1515

16+
use Bolt\error\MessageException;
1617
use Generator;
18+
use Laudis\Neo4j\Basic\Driver;
19+
use Throwable;
1720
use function getenv;
1821
use InvalidArgumentException;
1922
use Laudis\Neo4j\ClientBuilder;
@@ -470,6 +473,24 @@ public function testTimeoutRecovery(string $alias): void
470473
$tsx->run('CALL apoc.util.sleep(20000)');
471474
}
472475

476+
/**
477+
* @dataProvider connectionAliases
478+
*/
479+
public function testConstraintHandling(string $alias): void
480+
{
481+
$session = $this->getClient()->getDriver($alias)->createSession();
482+
483+
$session->run("CREATE (test:Test{id: '123'})");
484+
try {
485+
$session->run('CREATE CONSTRAINT ON (test:Test) ASSERT test.id IS UNIQUE');
486+
} catch (Throwable $e) {
487+
// We cannot use IF EXISTS on version 4.0
488+
$session->run('DROP CONSTRAINT ON (test:Test) ASSERT test.id IS UNIQUE');
489+
}
490+
$this->expectException(MessageException::class);
491+
$session->run("CREATE (test:Test {id: '123'}) RETURN test");
492+
}
493+
473494
/**
474495
* @dataProvider connectionAliases
475496
*/

0 commit comments

Comments
 (0)