2017 © Pedro Peláez
 

library neo4j-graphunit

Graph Database Assertion Tool for Neo4j

image

graphaware/neo4j-graphunit

Graph Database Assertion Tool for Neo4j

  • Wednesday, August 5, 2015
  • by ikwattro
  • Repository
  • 2 Watchers
  • 5 Stars
  • 374 Installations
  • PHP
  • 5 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 10 Versions
  • 1 % Grown

The README.md

Neo4j GraphUnit for PHP

Neo4j Graph Database Assertion Tool., (*1)

Build Status, (*2)

Usage

Require the library in your dev dependencies :, (*3)

composer require --dev graphaware/neo4j-graphunit

Create your BaseTestCase that will extend GraphAware\Neo4j\GraphUnit\Neo4jGraphDatabaseTestCase and declare the getConnection method that should return a Client instance., (*4)

To make things easier, you can just call the createConnection method of the parent class to bootstrap the connection., (*5)


namespace MyVendor\MyApp\Tests; use GraphAware\Neo4j\GraphUnit\Neo4jGraphDatabaseTestCase; abstract class MyAppBaseTestCase extends Neo4jGraphDatabaseTestCase { public function getConnection() { return $this->createConnection('localhost', 7474, 'neo4j', 'password'); } }

Assertions

assertNodeWithLabelExist

public function testNodeWillExist()
    {
        $q = 'CREATE (n:TestNode)';
        $this->getConnection()->sendCypherQuery($q);

        $this->assertNodeWithLabelExist('TestNode');
    }

assertNodesWithLabelCount

public function testMultipleNodesAreCreated()
    {
        $q = 'CREATE (n:TestNode), (n2:TestNode);
        $this->getConnection()->sendCypherQuery($q);

        $this->assertNodesWithLabelCount(2, 'TestNode');
    }

assertNodesCount

public function testMultipleNodesAreCreated()
    {
        $q = 'CREATE (n:TestNode), (n2:TestNode);
        $this->getConnection()->sendCypherQuery($q);

        $this->assertNodesCount(2);
    }

assertNodeHasRelationship

public function testMultipleNodesAreCreated()
    {
        $q = 'CREATE (n:User {name: "john"}), (n2:User {name: "mary"})-[:WORKS_AT]->(:Company {name:"Acme"}) RETURN n2;
        $result = $this->getConnection()->sendCypherQuery($q);

        $this->assertNodeHasRelationship($result->get('n2'), 'WORKS_AT', 'OUT');
    }

Reseting database states

You can easily reset the database state (deleting all nodes, relationships, schema indexes and constraints) during your setUp events :, (*6)

public function setUp()
{
    $this->resetDatabase();
}

If you don't want to delete the schema indexes and constraints, just call the emptyDatabase method :, (*7)

public function setUp()
{
    $this->emptyDatabase();
}

Preparing database states

You can just pass a Cypher pattern for preparing your database :, (*8)

public function setUp()
{
    $state = "(a:User {name:'Abed'})-[:WORKS_AT]->(:Company {name:'Vinelab'})
    (c:User {name:'Chris'})-[:WORKS_AT]->(:Company {name:'GraphAware'})
    (a)-[:FRIEND]->(c)";
    $this->prepareDatabase($state);
}

Asserting same graphs

The library can assert that the actual graph in the database matches a graph you pass as a Cypher pattern, example :, (*9)


public function testMyGraphIsGood() { $this->assertSameGraph("(:User {name:'John'})-[:WORKS_AT]->(c:Company {name:'Acme'})"); } // Returns true if the actual graph is identical, otherwise show errors in PHPUnit //1) GraphAware\Neo4j\GraphUnit\Tests\Integration\SimpleIntegrationTest::testAssertSame //Failed asserting that the expected graph is the same as the actual graph.

License

This library is released under the MIT License, please refer to the LICENSE file shipped with the library., (*10)

Author

Christophe Willemsen, (*11)

Github: https://github.com/ikwattro, (*12)

Twitter: https://twitter.com/ikwattro, (*13)

Credits

GraphAware Limited, (*14)

The Versions

05/08 2015

dev-master

9999999-dev

Graph Database Assertion Tool for Neo4j

  Sources   Download

MIT

The Requires

 

database nosql tests assertion graph neo4j

05/08 2015

1.0.8

1.0.8.0

Graph Database Assertion Tool for Neo4j

  Sources   Download

MIT

The Requires

 

database nosql tests assertion graph neo4j

05/08 2015

1.0.7

1.0.7.0

Graph Database Assertion Tool for Neo4j

  Sources   Download

MIT

The Requires

 

database nosql tests assertion graph neo4j

05/08 2015

1.0.6

1.0.6.0

Graph Database Assertion Tool for Neo4j

  Sources   Download

MIT

The Requires

 

database nosql tests assertion graph neo4j

05/08 2015

1.0.5

1.0.5.0

Graph Database Assertion Tool for Neo4j

  Sources   Download

MIT

The Requires

 

database nosql tests assertion graph neo4j

05/08 2015

1.0.4

1.0.4.0

Graph Database Assertion Tool for Neo4j

  Sources   Download

MIT

The Requires

 

database nosql tests assertion graph neo4j

04/08 2015

1.0.3

1.0.3.0

Graph Database Assertion Tool for Neo4j

  Sources   Download

MIT

The Requires

 

database nosql tests assertion graph neo4j

30/07 2015

1.0.2

1.0.2.0

Graph Database Assertion Tool for Neo4j

  Sources   Download

MIT

The Requires

 

database nosql tests assertion graph neo4j

30/07 2015

1.0.1

1.0.1.0

Graph Database Assertion Tool for Neo4j

  Sources   Download

MIT

The Requires

 

database nosql tests assertion graph neo4j

30/07 2015

1.0.0

1.0.0.0

Graph Database Assertion Tool for Neo4j

  Sources   Download

MIT

The Requires

 

database nosql tests assertion graph neo4j