Skip to content

Commit 2949af5

Browse files
committed
few alterations are done
1 parent 4c19946 commit 2949af5

6 files changed

+859
-891
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?php
2+
3+
namespace Neo4j\QueryAPI\Tests\Integration;
4+
5+
use PHPUnit\Framework\TestCase;
6+
use Neo4j\QueryAPI\Neo4jQueryAPI;
7+
use Neo4j\QueryAPI\Enums\AccessMode;
8+
use Neo4j\QueryAPI\Objects\Bookmarks;
9+
use Neo4j\QueryAPI\Exception\Neo4jException;
10+
11+
class AccessModesIntegrationTest extends TestCase
12+
{
13+
private Neo4jQueryAPI $api;
14+
15+
protected function setUp(): void
16+
{
17+
parent::setUp();
18+
$this->api = new Neo4jQueryAPI();
19+
}
20+
21+
public function testRunWithWriteAccessMode(): void
22+
{
23+
$result = $this->api->run(
24+
"CREATE (n:Person {name: 'Alice'}) RETURN n",
25+
[],
26+
'neo4j',
27+
null,
28+
null,
29+
AccessMode::WRITE
30+
);
31+
$this->assertNotNull($result);
32+
}
33+
34+
public function testRunWithReadAccessMode(): void
35+
{
36+
$result = $this->api->run(
37+
"MATCH (n) RETURN COUNT(n)",
38+
[],
39+
'neo4j',
40+
null,
41+
null,
42+
AccessMode::READ
43+
);
44+
$this->assertNotNull($result);
45+
}
46+
47+
public function testReadModeWithWriteQuery(): void
48+
{
49+
$this->expectException(Neo4jException::class);
50+
$this->api->run(
51+
"CREATE (n:Test {name: 'Test Node'})",
52+
[],
53+
'neo4j',
54+
new Bookmarks([]),
55+
null,
56+
AccessMode::READ
57+
);
58+
}
59+
60+
public function testWriteModeWithReadQuery(): void
61+
{
62+
$result = $this->api->run(
63+
"MATCH (n:Test) RETURN n",
64+
[],
65+
'neo4j',
66+
null,
67+
null,
68+
AccessMode::WRITE
69+
);
70+
$this->assertNotNull($result);
71+
}
72+
}
73+
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
namespace Neo4j\QueryAPI\Tests\Integration;
3+
4+
use PHPUnit\Framework\TestCase;
5+
use Neo4j\QueryAPI\Neo4jQueryAPI;
6+
use Neo4j\QueryAPI\Objects\Bookmarks;
7+
use Neo4j\QueryAPI\Results\ResultSet;
8+
9+
class BookmarksIntegrationTest extends TestCase
10+
{
11+
private Neo4jQueryAPI $api;
12+
13+
protected function setUp(): void
14+
{
15+
parent::setUp();
16+
$this->api = new Neo4jQueryAPI(/* pass necessary config */);
17+
}
18+
19+
public function testCreateBookmarks(): void
20+
{
21+
$result1 = $this->api->run('CREATE (x:Node {hello: "world"})');
22+
$bookmarks = $result1->getBookmarks() ?? new Bookmarks([]);
23+
24+
$result2 = $this->api->run('CREATE (x:Node {hello: "world2"})');
25+
$bookmarks->addBookmarks($result2->getBookmarks()->getBookmarks());
26+
27+
$result3 = $this->api->run('MATCH (x:Node {hello: "world2"}) RETURN x');
28+
29+
$this->assertCount(1, iterator_to_array($result3));
30+
}
31+
}

0 commit comments

Comments
 (0)