Skip to content

Commit 0914c91

Browse files
Add end-to-end test for README example
1 parent 48b086d commit 0914c91

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
@@ -0,0 +1,36 @@
1+
<?php declare(strict_types=1);
2+
/*
3+
* This file is part of php-cypher-dsl.
4+
*
5+
* Copyright (C) Wikibase Solutions
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
namespace WikibaseSolutions\CypherDSL\Tests\EndToEnd;
11+
12+
use PHPUnit\Framework\TestCase;
13+
use WikibaseSolutions\CypherDSL\Query;
14+
15+
/**
16+
* This class contains some end-to-end tests to test the examples in the wiki.
17+
*
18+
* @coversNothing
19+
*
20+
* @see https://github.com/neo4j-php/php-cypher-dsl/wiki
21+
*/
22+
final class ExamplesTest extends TestCase
23+
{
24+
public function testReadmeExample(): void
25+
{
26+
$tom = Query::node("Person")->withProperties(["name" => "Tom Hanks"]);
27+
$coActors = Query::node();
28+
29+
$statement = Query::new()
30+
->match($tom->relationshipTo(Query::node(), "ACTED_IN")->relationshipFrom($coActors, "ACTED_IN"))
31+
->returning($coActors->property("name"))
32+
->build();
33+
34+
$this->assertStringMatchesFormat("MATCH (:Person {name: 'Tom Hanks'})-[:ACTED_IN]->()<-[:ACTED_IN]-(%s) RETURN %s.name", $statement);
35+
}
36+
}

0 commit comments

Comments
 (0)