Skip to content

Commit fcd2297

Browse files
committed
reworked driver parity test to use envirementawareintegrationtest
1 parent efd1dff commit fcd2297

File tree

3 files changed

+21
-93
lines changed

3 files changed

+21
-93
lines changed

tests/Integration/DriverParityTest.php

Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
namespace Laudis\Neo4j\Tests\Integration;
1515

16-
use Laudis\Neo4j\Contracts\ClientInterface;
1716
use Laudis\Neo4j\Contracts\FormatterInterface;
1817
use Laudis\Neo4j\Formatter\SummarizedResultFormatter;
1918
use Laudis\Neo4j\Tests\Fixtures\MoviesFixture;
@@ -22,46 +21,36 @@
2221
/**
2322
* @psalm-suppress all
2423
*/
25-
final class DriverParityTest extends SelectableDriverIntegrationTestCase
24+
final class DriverParityTest extends EnvironmentAwareIntegrationTest
2625
{
27-
private const TESTABLE_SCHEMES = ['bolt', 'http'];
28-
29-
protected function setUp(): void
26+
public static function setUpBeforeClass(): void
3027
{
31-
parent::setUp();
32-
$client = $this->getClient();
33-
34-
$client->run('MATCH (n) DETACH DELETE n');
35-
$client->run(MoviesFixture::CQL);
28+
parent::setUpBeforeClass();
29+
foreach (self::connectionAliases() as $alias) {
30+
$session = self::$client->getDriver($alias[0])->createSession();
31+
$session->run('MATCH (x) DETACH DELETE x', []);
32+
$session->run(MoviesFixture::CQL, []);
33+
}
3634
}
3735

3836
protected static function formatter(): FormatterInterface
3937
{
4038
return SummarizedResultFormatter::create();
4139
}
4240

43-
public function testCanHandleMapLiterals(): void
41+
/**
42+
* @dataProvider connectionAliases
43+
*/
44+
public function testCanHandleMapLiterals(string $alias): void
4445
{
45-
$this->runParityTest(function (ClientInterface $client) {
46-
$results = $client->run('MATCH (n:Person)-[r:ACTED_IN]->(m) RETURN n, {movie: m, roles: r.roles} AS actInfo LIMIT 5');
46+
$results = $this->getClient()->run('MATCH (n:Person)-[r:ACTED_IN]->(m) RETURN n, {movie: m, roles: r.roles} AS actInfo LIMIT 5', [], $alias);
4747

48-
foreach ($results as $result) {
49-
$actorInfo = $result->get('actInfo');
48+
foreach ($results as $result) {
49+
$actorInfo = $result->get('actInfo');
5050

51-
$this->assertInstanceOf(CypherMap::class, $actorInfo);
52-
$this->assertTrue($actorInfo->hasKey('roles'));
53-
$this->assertTrue($actorInfo->hasKey('movie'));
54-
}
55-
});
56-
}
57-
58-
private function runParityTest(callable $test): void
59-
{
60-
foreach (self::TESTABLE_SCHEMES as $scheme) {
61-
$client = $this->getClientForScheme($scheme);
62-
echo 'Testing '.$scheme.' for '.$this->getName().PHP_EOL;
63-
$test($client);
64-
echo $scheme.' passed'.PHP_EOL;
51+
$this->assertInstanceOf(CypherMap::class, $actorInfo);
52+
$this->assertTrue($actorInfo->hasKey('roles'));
53+
$this->assertTrue($actorInfo->hasKey('movie'));
6554
}
6655
}
6756
}

tests/Integration/EnvironmentAwareIntegrationTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ protected static function createClient(): ClientInterface
6666
/**
6767
* @return non-empty-array<array-key, array{0: string}>
6868
*/
69-
public function connectionAliases(): iterable
69+
public static function connectionAliases(): iterable
7070
{
7171
Dotenv::createImmutable(__DIR__.'/../../')->safeLoad();
72-
$connections = $this->getConnections();
72+
$connections = static::getConnections();
7373

7474
$tbr = [];
7575
foreach ($connections as $i => $connection) {
@@ -97,7 +97,7 @@ protected static function buildConnections(): array
9797
/**
9898
* @return list<string>
9999
*/
100-
protected function getConnections(): array
100+
protected static function getConnections(): array
101101
{
102102
return self::buildConnections();
103103
}

tests/Integration/SelectableDriverIntegrationTestCase.php

Lines changed: 0 additions & 61 deletions
This file was deleted.

0 commit comments

Comments
 (0)