Skip to content

Commit 3da19a5

Browse files
Add CALL {} (subquery) example tests
1 parent 0914c91 commit 3da19a5

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

tests/end-to-end/ExamplesTest.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,40 @@ public function testReadmeExample(): void
3333

3434
$this->assertStringMatchesFormat("MATCH (:Person {name: 'Tom Hanks'})-[:ACTED_IN]->()<-[:ACTED_IN]-(%s) RETURN %s.name", $statement);
3535
}
36+
37+
public function testCallSubqueryClauseExample1(): void
38+
{
39+
$query = Query::new()
40+
->call(static function (Query $query): void
41+
{
42+
$query->create(Query::node("Person"));
43+
})
44+
->build();
45+
46+
$this->assertSame("CALL { CREATE (:Person) }", $query);
47+
}
48+
49+
public function testCallSubqueryClauseExample2(): void
50+
{
51+
$subQuery = Query::new()->create(Query::node("Person"));
52+
$query = Query::new()
53+
->call($subQuery)
54+
->build();
55+
56+
$this->assertSame("CALL { CREATE (:Person) }", $query);
57+
}
58+
59+
public function testCallSubqueryClauseExample3(): void
60+
{
61+
$person = Query::variable();
62+
$query = Query::new()
63+
->match(Query::node('Person')->withVariable($person))
64+
->call(static function (Query $query) use ($person): void
65+
{
66+
$query->remove($person->labeled('Person'));
67+
}, [$person])
68+
->build();
69+
70+
$this->assertStringMatchesFormat("MATCH (%s:Person) CALL { WITH %s REMOVE %s:Person }", $query);
71+
}
3672
}

0 commit comments

Comments
 (0)