Skip to content

Commit e6508f3

Browse files
committed
added test for bookmark updates
1 parent 371f216 commit e6508f3

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

src/Bolt/BoltConnection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,11 @@ public function reset(): void
210210
*
211211
* Any of the preconditioned states are: 'READY', 'INTERRUPTED'.
212212
*/
213-
public function begin(?string $database, ?float $timeout): void
213+
public function begin(?string $database, ?float $timeout, BookmarkHolder $holder): void
214214
{
215215
$this->consumeResults();
216216

217-
$extra = $this->buildRunExtra($database, $timeout);
217+
$extra = $this->buildRunExtra($database, $timeout, $holder);
218218
try {
219219
$this->protocol()->begin($extra);
220220
} catch (IgnoredException $e) {

src/Bolt/Session.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ private function startTransaction(TransactionConfiguration $config, SessionConfi
180180
try {
181181
$connection = $this->acquireConnection($config, $sessionConfig);
182182

183-
$connection->begin($this->config->getDatabase(), $config->getTimeout());
183+
$connection->begin($this->config->getDatabase(), $config->getTimeout(), $this->bookmarkHolder);
184184
} catch (MessageException $e) {
185185
if (isset($connection) && $connection->getServerState() === 'FAILED') {
186186
$connection->reset();

tests/Integration/BoltDriverIntegrationTest.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
use Exception;
1919
use Laudis\Neo4j\Bolt\BoltDriver;
2020
use Laudis\Neo4j\Common\Uri;
21+
use Laudis\Neo4j\Contracts\TransactionInterface;
22+
use Laudis\Neo4j\Databags\SummarizedResult;
2123
use PHPUnit\Framework\TestCase;
2224
use Psr\Http\Message\UriInterface;
2325

@@ -103,4 +105,34 @@ public function testInvalidSocket(): void
103105
$this->expectException(ConnectException::class);
104106
$driver->createSession()->run('RETURN 1');
105107
}
108+
109+
public function testBookmarkUpdates(): void
110+
{
111+
if ($this->uri === null) {
112+
self::markTestSkipped('No bolt uri provided');
113+
}
114+
115+
$session = BoltDriver::create($this->uri->__toString())->createSession();
116+
$bookmark = $session->getLastBookmark();
117+
$this->assertEquals([], $bookmark->values());
118+
$this->assertTrue($bookmark->isEmpty());
119+
$previousBookmark = $bookmark;
120+
121+
/** @var SummarizedResult $result */
122+
$result = $session->run('MATCH (x) RETURN x');
123+
$result->preload();
124+
125+
$bookmark = $session->getLastBookmark();
126+
$this->assertFalse($bookmark->isEmpty());
127+
$this->assertNotEquals($previousBookmark->values(), $bookmark->values());
128+
$previousBookmark = $bookmark;
129+
130+
/** @var SummarizedResult $result */
131+
$result = $session->run('CREATE (x:Node)');
132+
$result->preload();
133+
134+
$bookmark = $session->getLastBookmark();
135+
$this->assertFalse($bookmark->isEmpty());
136+
$this->assertNotEquals($previousBookmark->values(), $bookmark->values());
137+
}
106138
}

0 commit comments

Comments
 (0)