Skip to content
This repository was archived by the owner on Dec 1, 2021. It is now read-only.

Commit fa63c65

Browse files
authored
Merge pull request #106 from graphaware/issue-105
added test for issue 105, fix #105
2 parents c6384ca + 7d2b5cf commit fa63c65

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

tests/Issues/Issue105Test.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
namespace GraphAware\Neo4j\Client\Tests\Issues;
4+
5+
use GraphAware\Neo4j\Client\Tests\Integration\IntegrationTestCase;
6+
7+
/**
8+
*
9+
* @group issue-105
10+
*/
11+
class Issue105Test extends IntegrationTestCase
12+
{
13+
public function testMatchNodeCreatedEarlierInStackWithEmptyDbState()
14+
{
15+
$this->emptyDb();
16+
$stack = $this->client->stack();
17+
$stack->push('CREATE (n:Node {id:1})');
18+
$stack->push('MATCH (n:Node {id: 1}) CREATE (n2:Node {id: 2}) MERGE (n)-[r:RELATES]->(n2) RETURN id(r)');
19+
$results = $this->client->runStack($stack);
20+
21+
$this->assertCount(2, $results);
22+
$relId = $results->results()[1]->firstRecord()->get('id(r)');
23+
$this->assertNotNull($relId);
24+
}
25+
26+
public function testMatchNodeFromDbInAStack()
27+
{
28+
$this->emptyDb();
29+
// Create Region node
30+
$this->client->run('CREATE (n:Region {name: "Picardie"})');
31+
32+
// Create stack, create department in first push, match department and region and relates them in second push
33+
$stack = $this->client->stack();
34+
$stack->push('CREATE (d:Department {name:"Somme"})');
35+
$stack->push('MATCH (d:Department {name:"Somme"}), (r:Region {name:"Picardie"}) MERGE (d)-[:IN_REGION]->(r)');
36+
$this->client->runStack($stack);
37+
38+
// Assert that the relationship is in the graph after stack execution
39+
40+
$result = $this->client->run('MATCH (n:Department {name:"Somme"})-[r:IN_REGION]->(re:Region {name:"Picardie"}) RETURN n, r, re');
41+
$this->assertEquals(1, $result->size());
42+
$this->assertEquals('Picardie', $result->firstRecord()->nodeValue('re')->value('name'));
43+
}
44+
}

0 commit comments

Comments
 (0)