diff --git a/composer.json b/composer.json index 21578d0..24cdc05 100644 --- a/composer.json +++ b/composer.json @@ -37,7 +37,7 @@ }, "require-dev": { "friendsofphp/php-cs-fixer": "^2.0", - "phpunit/phpunit": "^4.0", + "phpunit/phpunit": "^8.5", "symfony/stopwatch": "^4.4 || ^5.0" }, "autoload": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index c63affb..93a9620 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,15 +1,15 @@ - + ./tests - - tests - vendor - bin - + + src + diff --git a/tests/Example/ExampleTestCase.php b/tests/Example/ExampleTestCase.php index c21d551..4ea28e7 100644 --- a/tests/Example/ExampleTestCase.php +++ b/tests/Example/ExampleTestCase.php @@ -12,15 +12,16 @@ namespace GraphAware\Neo4j\Client\Tests\Example; use GraphAware\Neo4j\Client\ClientBuilder; +use PHPUnit\Framework\TestCase; -abstract class ExampleTestCase extends \PHPUnit_Framework_TestCase +abstract class ExampleTestCase extends TestCase { /** * @var \GraphAware\Neo4j\Client\Client */ protected $client; - public function setUp() + public function setUp(): void { $boltUrl = 'bolt://localhost'; if (isset($_ENV['NEO4J_USER'])) { diff --git a/tests/Integration/BuildWithEventListenersIntegrationTest.php b/tests/Integration/BuildWithEventListenersIntegrationTest.php index 60e1392..245e297 100644 --- a/tests/Integration/BuildWithEventListenersIntegrationTest.php +++ b/tests/Integration/BuildWithEventListenersIntegrationTest.php @@ -14,13 +14,14 @@ use GraphAware\Neo4j\Client\ClientBuilder; use GraphAware\Neo4j\Client\Exception\Neo4jExceptionInterface; use GraphAware\Neo4j\Client\Neo4jClientEvents; +use PHPUnit\Framework\TestCase; /** * Class BuildWithEventListenersIntegrationTest. * * @group listener */ -class BuildWithEventListenersIntegrationTest extends \PHPUnit_Framework_TestCase +class BuildWithEventListenersIntegrationTest extends TestCase { /** * @return string @@ -49,7 +50,7 @@ public function testListenersAreRegistered() ->registerEventListener(Neo4jClientEvents::NEO4J_ON_FAILURE, [$listener, 'onFailure']) ->build(); - $result = $client->run('MATCH (n) RETURN count(n)'); + $client->run('MATCH (n) RETURN count(n)'); $this->assertTrue($listener->hookedPreRun); $this->assertTrue($listener->hookedPostRun); } diff --git a/tests/Integration/ClientGetExceptionIntegrationTest.php b/tests/Integration/ClientGetExceptionIntegrationTest.php index a5b33f6..ad60fe2 100644 --- a/tests/Integration/ClientGetExceptionIntegrationTest.php +++ b/tests/Integration/ClientGetExceptionIntegrationTest.php @@ -13,8 +13,9 @@ use GraphAware\Neo4j\Client\ClientBuilder; use GraphAware\Neo4j\Client\Exception\Neo4jException; +use PHPUnit\Framework\TestCase; -class ClientGetExceptionIntegrationTest extends \PHPUnit_Framework_TestCase +class ClientGetExceptionIntegrationTest extends TestCase { public function testExceptionHandling() { @@ -32,7 +33,7 @@ public function testExceptionHandling() ->addConnection('default', $boltUrl) ->build(); - $this->setExpectedException(Neo4jException::class); - $result = $client->run('CREATE (n:Cool'); + self::expectException(Neo4jException::class); + $client->run('CREATE (n:Cool'); } } diff --git a/tests/Integration/ClientSetupIntegrationTest.php b/tests/Integration/ClientSetupIntegrationTest.php index 5c444cd..86d3fbd 100644 --- a/tests/Integration/ClientSetupIntegrationTest.php +++ b/tests/Integration/ClientSetupIntegrationTest.php @@ -18,13 +18,14 @@ use GraphAware\Neo4j\Client\Connection\ConnectionManager; use GraphAware\Neo4j\Client\HttpDriver\Driver as HttpDriver; use InvalidArgumentException; +use PHPUnit\Framework\TestCase; /** * Class ClientSetupIntegrationTest. * * @group setup */ -class ClientSetupIntegrationTest extends \PHPUnit_Framework_TestCase +class ClientSetupIntegrationTest extends TestCase { public function testClientSetupWithOneConnection() { @@ -104,8 +105,8 @@ public function testSecondIsMasterCallOverridesPreviousOne() public function testExceptionIsThrownWhenMasterAliasDoesntExist() { - $this->setExpectedException(InvalidArgumentException::class); - $client = ClientBuilder::create() + self::expectException(InvalidArgumentException::class); + ClientBuilder::create() ->addConnection('default', 'http://localhost:7474') ->addConnection('conn2', 'http://localhost:7575') ->addConnection('conn3', 'http://localhost:7676') diff --git a/tests/Integration/CypherIntegrationTest.php b/tests/Integration/CypherIntegrationTest.php index accacb4..3ef9dcc 100644 --- a/tests/Integration/CypherIntegrationTest.php +++ b/tests/Integration/CypherIntegrationTest.php @@ -17,10 +17,11 @@ use GraphAware\Common\Type\Path; use GraphAware\Neo4j\Client\Formatter\Type\Node as HttpNode; use GraphAware\Neo4j\Client\Formatter\Type\Relationship as HttpRelationship; +use InvalidArgumentException; class CypherIntegrationTest extends IntegrationTestCase { - public function setUp() + public function setUp(): void { parent::setUp(); $this->emptyDb(); @@ -58,10 +59,8 @@ public function testPathIsReturned() $this->assertInstanceOf(Path::class, $record2->get('p')); } - /** - * @expectedException InvalidArgumentException - */ public function testExceptionIsThrownOnEmptyStatement() { + self::expectException(InvalidArgumentException::class); $query = ''; $this->client->run($query); } diff --git a/tests/Integration/IntegrationTestCase.php b/tests/Integration/IntegrationTestCase.php index c0daa5d..ff40ac5 100644 --- a/tests/Integration/IntegrationTestCase.php +++ b/tests/Integration/IntegrationTestCase.php @@ -12,15 +12,16 @@ namespace GraphAware\Neo4j\Client\Tests\Integration; use GraphAware\Neo4j\Client\ClientBuilder; +use PHPUnit\Framework\TestCase; -class IntegrationTestCase extends \PHPUnit_Framework_TestCase +class IntegrationTestCase extends TestCase { /** * @var \GraphAware\Neo4j\Client\Client */ protected $client; - public function setUp() + public function setUp(): void { $connections = array_merge($this->getConnections(), $this->getAdditionalConnections()); diff --git a/tests/Integration/ResultIntegrationTest.php b/tests/Integration/ResultIntegrationTest.php index 0c1c66a..7a92ea8 100644 --- a/tests/Integration/ResultIntegrationTest.php +++ b/tests/Integration/ResultIntegrationTest.php @@ -14,6 +14,7 @@ use GraphAware\Common\Type\Node; use GraphAware\Common\Type\Relationship; use InvalidArgumentException; +use RuntimeException; /** * Class ResultIntegrationTest. @@ -46,7 +47,7 @@ public function testExceptionIsThrownForInvalidNodeValue() $result = $this->client->run('CREATE (n) RETURN id(n) as id'); $record = $result->firstRecord(); - $this->setExpectedException(InvalidArgumentException::class); + self::expectException(InvalidArgumentException::class); $record->nodeValue('id'); } @@ -56,7 +57,7 @@ public function testExceptionIsThrownForInvalidRelationshipValue() $result = $this->client->run('CREATE (n)-[r:KNOWS]->(me) RETURN id(r) as r'); $record = $result->firstRecord(); - $this->setExpectedException(InvalidArgumentException::class); + self::expectException(InvalidArgumentException::class); $record->relationshipValue('r'); } @@ -67,7 +68,7 @@ public function testExceptionIsThrownWhenTryingToGetRecordOnEmptyCursor() { $this->emptyDb(); $result = $this->client->run('MATCH (n) RETURN n'); - $this->setExpectedException(\RuntimeException::class); + self::expectException(RuntimeException::class); $result->firstRecord(); } @@ -78,7 +79,7 @@ public function testExceptionIsThrownWhenTryingToGetRecordOnEmptyCursorWithGetRe { $this->emptyDb(); $result = $this->client->run('MATCH (n) RETURN n'); - $this->setExpectedException(\RuntimeException::class); + self::expectException(RuntimeException::class); $result->getRecord(); } } diff --git a/tests/Issues/DrupalIssueTest.php b/tests/Issues/DrupalIssueTest.php index f8211e6..e3a4e71 100644 --- a/tests/Issues/DrupalIssueTest.php +++ b/tests/Issues/DrupalIssueTest.php @@ -1,6 +1,9 @@ addConnection('default', 'bolt://neo4j:sfadfewfn;kewvljnfd@ssl+graphene.com', null); + $this->addConnection('bolt://neo4j:sfadfewfn;kewvljnfd@ssl+graphene.com', null); + self::assertTrue(true); } - private function addConnection($alias, $uri, $config) + private function addConnection($uri, $config) { if (substr($uri, 0, 7) === 'bolt://') { $parts = explode('bolt://', $uri ); @@ -28,14 +32,11 @@ private function addConnection($alias, $uri, $config) $u = $ups[0]; $p = $ups[1]; $uri = 'bolt://'.str_replace('ssl+', '', $split); - $config = \GraphAware\Bolt\Configuration::newInstance() + $config = Configuration::newInstance() ->withCredentials($u, $p) - ->withTLSMode(\GraphAware\Bolt\Configuration::TLSMODE_REQUIRED); + ->withTLSMode(Configuration::TLSMODE_REQUIRED); } } } - - var_dump($uri); - var_dump($config); } -} \ No newline at end of file +} diff --git a/tests/Issues/Issue143Test.php b/tests/Issues/Issue143Test.php index b84b87d..b0e9797 100644 --- a/tests/Issues/Issue143Test.php +++ b/tests/Issues/Issue143Test.php @@ -13,7 +13,7 @@ */ class Issue143Test extends IntegrationTestCase { - public function setUp() + public function setUp(): void { $connections = array_merge($this->getConnections(), $this->getAdditionalConnections()); @@ -38,5 +38,7 @@ public function testStackUsesMasterForWritesWhenOneisSet() $stack->pushWrite('CREATE (n)'); $this->client->runStack($stack); } + + self::markTestIncomplete('Incomplete test'); } -} \ No newline at end of file +} diff --git a/tests/Issues/ReportedIssuesTest.php b/tests/Issues/ReportedIssuesTest.php index 8b03fd7..1ca0f89 100644 --- a/tests/Issues/ReportedIssuesTest.php +++ b/tests/Issues/ReportedIssuesTest.php @@ -13,7 +13,7 @@ use GraphAware\Neo4j\Client\Exception\Neo4jException; use GraphAware\Neo4j\Client\Tests\Integration\IntegrationTestCase; -use Symfony\Component\Yaml\Exception\RuntimeException; +use RuntimeException; class ReportedIssuesTest extends IntegrationTestCase { @@ -26,7 +26,7 @@ public function testTryingToDeleteNodeWithRelsInTransactionShouldFail() $this->createNodeWithRels(); $tx = $this->client->transaction(); $tx->push('MATCH (n:Node) DELETE n'); - $this->setExpectedException(Neo4jException::class); + self::expectException(Neo4jException::class); $tx->commit(); } diff --git a/tests/Unit/Connection/ConnectionUnitTest.php b/tests/Unit/Connection/ConnectionUnitTest.php index 63a2834..1331754 100644 --- a/tests/Unit/Connection/ConnectionUnitTest.php +++ b/tests/Unit/Connection/ConnectionUnitTest.php @@ -13,12 +13,13 @@ use GraphAware\Neo4j\Client\Connection\Connection; use GraphAware\Neo4j\Client\HttpDriver\Driver as HttpDriver; +use PHPUnit\Framework\TestCase; /** * @group unit * @group connection */ -class ConnectionUnitTest extends \PHPUnit_Framework_TestCase +class ConnectionUnitTest extends TestCase { public function testConnectionInstantiation() {