Skip to content

Commit

Permalink
PHPUnit upgraded to 8.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandre-T committed Jul 2, 2020
1 parent 7eaa4ce commit d78c5f2
Show file tree
Hide file tree
Showing 13 changed files with 51 additions and 42 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
12 changes: 6 additions & 6 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?xml version="1.0"?>
<phpunit bootstrap="./vendor/autoload.php" colors="true" verbose="true">
<phpunit bootstrap="./vendor/autoload.php" colors="true" verbose="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd">
<testsuites>
<testsuite name="GraphAware Neo4j PHP Client Test Suite">
<directory>./tests</directory>
</testsuite>
</testsuites>
<filter>
<blacklist>
<directory>tests</directory>
<directory>vendor</directory>
<directory>bin</directory>
</blacklist>
<whitelist>
<directory>src</directory>
</whitelist>
</filter>
</phpunit>
5 changes: 3 additions & 2 deletions tests/Example/ExampleTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'])) {
Expand Down
5 changes: 3 additions & 2 deletions tests/Integration/BuildWithEventListenersIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
Expand Down
7 changes: 4 additions & 3 deletions tests/Integration/ClientGetExceptionIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand All @@ -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');
}
}
7 changes: 4 additions & 3 deletions tests/Integration/ClientSetupIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down Expand Up @@ -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')
Expand Down
7 changes: 3 additions & 4 deletions tests/Integration/CypherIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
}
Expand Down
5 changes: 3 additions & 2 deletions tests/Integration/IntegrationTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
9 changes: 5 additions & 4 deletions tests/Integration/ResultIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use GraphAware\Common\Type\Node;
use GraphAware\Common\Type\Relationship;
use InvalidArgumentException;
use RuntimeException;

/**
* Class ResultIntegrationTest.
Expand Down Expand Up @@ -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');
}

Expand All @@ -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');
}

Expand All @@ -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();
}

Expand All @@ -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();
}
}
21 changes: 11 additions & 10 deletions tests/Issues/DrupalIssueTest.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
<?php

namespace GraphAware\Neo4j\Client\Tests;
namespace GraphAware\Neo4j\Client\Tests\Issues;

use GraphAware\Bolt\Configuration;
use PHPUnit\Framework\TestCase;

/**
* Class DrupalIssueTest
* @package GraphAware\Neo4j\Client\Tests
*
* @group drupal
*/
class DrupalIssueTest extends \PHPUnit_Framework_TestCase
class DrupalIssueTest extends TestCase
{
public function testDrupalConversion()
{
$this->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 );
Expand All @@ -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);
}
}
}
6 changes: 4 additions & 2 deletions tests/Issues/Issue143Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/
class Issue143Test extends IntegrationTestCase
{
public function setUp()
public function setUp(): void
{
$connections = array_merge($this->getConnections(), $this->getAdditionalConnections());

Expand All @@ -38,5 +38,7 @@ public function testStackUsesMasterForWritesWhenOneisSet()
$stack->pushWrite('CREATE (n)');
$this->client->runStack($stack);
}

self::markTestIncomplete('Incomplete test');
}
}
}
4 changes: 2 additions & 2 deletions tests/Issues/ReportedIssuesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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();
}

Expand Down
3 changes: 2 additions & 1 deletion tests/Unit/Connection/ConnectionUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down

0 comments on commit d78c5f2

Please sign in to comment.