ResultIntegrationTest.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace GraphAware\Neo4j\GraphUnit\Tests\Integration;
  3. use GraphAware\NeoClient\Formatter\Tests\Integration\IntegrationBaseTest;
  4. class ResultIntegrationTest extends IntegrationBaseTest
  5. {
  6. public function setUp()
  7. {
  8. $this->emptyDatabase();
  9. }
  10. /**
  11. * @group result
  12. */
  13. public function testSingleResult()
  14. {
  15. $q = 'CREATE (n:User {name:"Michael"})';
  16. $this->conn->sendCypherQuery($q);
  17. $query = 'MATCH (n:User) WITH n LIMIT 1 RETURN n';
  18. $result = $this->conn->sendCypherQuery($query)->getSingleResult();
  19. $this->assertCount(1, $result->get('n'));
  20. $this->assertInstanceOf('Graphaware\NeoClient\Formatter\Graph\Node', $result->get('n', true));
  21. }
  22. /**
  23. * @group result
  24. */
  25. public function testResultWithRelationships()
  26. {
  27. $g = '(m:User {name:"Michael"})-[:FOLLOWS]->(:User {name:"Vince"}),
  28. (m)-[:FOLLOWS]->(:User {name:"Luanne"}),
  29. (m)-[:FOLLOWS]->(:User {name:"Adam"})';
  30. $this->prepareDatabase($g);
  31. $q = 'MATCH (m:User {name:"Michael"}) WITH m LIMIT 1
  32. OPTIONAL MATCH (m)-[r:FOLLOWS]->(other)
  33. RETURN m, r, other';
  34. $result = $this->conn->sendCypherQuery($q)->getSingleResult();
  35. $this->assertCount(1, $result->get('m'));
  36. $this->assertCount(3, $result->get('other'));
  37. }
  38. }