Skip to content

Commit 84cb974

Browse files
committed
Added negative test case for periodic commits
references #64
1 parent 4b02848 commit 84cb974

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tests/Integration/ComplexQueryTests.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@
1717
use function getenv;
1818
use InvalidArgumentException;
1919
use Laudis\Neo4j\Contracts\FormatterInterface;
20+
use Laudis\Neo4j\Exception\Neo4jException;
2021
use Laudis\Neo4j\Formatter\BasicFormatter;
2122
use Laudis\Neo4j\ParameterHelper;
23+
use function str_starts_with;
2224

2325
/**
2426
* @psalm-import-type BasicResults from \Laudis\Neo4j\Formatter\BasicFormatter
@@ -238,4 +240,28 @@ public function testPeriodicCommit(string $alias): void
238240
$result = $this->client->run('MATCH (n:File) RETURN count(n) AS count');
239241
self::assertEquals(20, $result->first()->get('count'));
240242
}
243+
244+
/**
245+
* @dataProvider connectionAliases
246+
*/
247+
public function testPeriodicCommitFail(string $alias): void
248+
{
249+
if (getenv('TESTING_ENVIRONMENT') !== 'local') {
250+
self::markTestSkipped('Only local environment has access to local files');
251+
}
252+
253+
if (str_starts_with($alias, 'http')) {
254+
self::markTestSkipped('HTTP allows periodic commits during an actual transaction');
255+
}
256+
257+
$this->expectException(Neo4jException::class);
258+
259+
$tsx = $this->client->beginTransaction([], $alias);
260+
$tsx->run(<<<CYPHER
261+
USING PERIODIC COMMIT 10
262+
LOAD CSV FROM 'file:///csv-example.csv' AS line
263+
MERGE (n:File {name: line[0]});
264+
CYPHER);
265+
$tsx->commit();
266+
}
241267
}

0 commit comments

Comments
 (0)