Skip to content

Commit 2f1eaf0

Browse files
committed
streamlined tests
1 parent 4da51a0 commit 2f1eaf0

17 files changed

+381
-1275
lines changed

src/Basic/UnmanagedTransaction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,6 @@ public function isRolledBack(): bool
8686

8787
public function isFinished(): bool
8888
{
89-
return $this->tsx->isRolledBack();
89+
return $this->tsx->isFinished();
9090
}
9191
}

tests/Integration/BasicDriverTest.php

Lines changed: 5 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -13,51 +13,17 @@
1313

1414
namespace Laudis\Neo4j\Tests\Integration;
1515

16-
use Dotenv\Dotenv;
17-
18-
use function explode;
19-
use function is_string;
20-
2116
use Laudis\Neo4j\Authentication\Authenticate;
2217
use Laudis\Neo4j\Basic\Driver;
2318
use Laudis\Neo4j\Bolt\BoltDriver;
24-
use Laudis\Neo4j\Common\Uri;
2519
use Laudis\Neo4j\Exception\Neo4jException;
2620
use Laudis\Neo4j\Types\CypherMap;
27-
use PHPUnit\Framework\TestCase;
2821

29-
final class BasicDriverTest extends TestCase
22+
final class BasicDriverTest extends EnvironmentAwareIntegrationTest
3023
{
31-
/**
32-
* @return non-empty-array<string, array{0: string}>
33-
*/
34-
public function getConnections(): array
35-
{
36-
/** @var string|mixed $connections */
37-
$connections = $_ENV['CONNECTIONS'] ?? false;
38-
if (!is_string($connections)) {
39-
Dotenv::createImmutable(__DIR__.'/../../')->safeLoad();
40-
/** @var string|mixed $connections */
41-
$connections = $_ENV['CONNECTIONS'] ?? false;
42-
if (!is_string($connections)) {
43-
$connections = 'bolt://neo4j:test@neo4j,neo4j://neo4j:test@core1,http://neo4j:test@neo4j';
44-
}
45-
}
46-
47-
$tbr = [];
48-
foreach (explode(',', $connections) as $connection) {
49-
$tbr[$connection] = [$connection];
50-
}
51-
52-
return $tbr;
53-
}
54-
55-
/**
56-
* @dataProvider getConnections
57-
*/
58-
public function testFullWalk(string $connection): void
24+
public function testFullWalk(): void
5925
{
60-
$driver = Driver::create($connection);
26+
$driver = Driver::create($this->getUri());
6127

6228
$session = $driver->createSession();
6329

@@ -73,12 +39,9 @@ public function testFullWalk(string $connection): void
7339
self::assertEquals(0, $id);
7440
}
7541

76-
/**
77-
* @dataProvider getConnections
78-
*/
79-
public function testInvalidAuth(string $connection): void
42+
public function testInvalidAuth(): void
8043
{
81-
$uri = Uri::create($connection)->withUserInfo('');
44+
$uri = $this->getUri()->withUserInfo('');
8245

8346
$this->expectException(Neo4jException::class);
8447
BoltDriver::create($uri, null, Authenticate::basic('x', 'y'))

tests/Integration/BoltDriverIntegrationTest.php

Lines changed: 9 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -14,58 +14,21 @@
1414
namespace Laudis\Neo4j\Tests\Integration;
1515

1616
use Bolt\error\ConnectException;
17-
use Dotenv\Dotenv;
1817
use Exception;
1918
use Laudis\Neo4j\Bolt\BoltDriver;
20-
use Laudis\Neo4j\Common\Uri;
2119
use Laudis\Neo4j\Databags\SummarizedResult;
22-
use PHPUnit\Framework\TestCase;
23-
use Psr\Http\Message\UriInterface;
2420

25-
final class BoltDriverIntegrationTest extends TestCase
21+
final class BoltDriverIntegrationTest extends EnvironmentAwareIntegrationTest
2622
{
27-
private ?UriInterface $uri;
28-
29-
protected function setUp(): void
30-
{
31-
parent::setUp();
32-
$this->uri = $this->getBoltUri();
33-
}
34-
35-
private function getBoltUri(): ?UriInterface
36-
{
37-
/** @var string|mixed $connections */
38-
$connections = $_ENV['CONNECTIONS'] ?? false;
39-
if (!is_string($connections)) {
40-
Dotenv::createImmutable(__DIR__.'/../../')->load();
41-
/** @var string|mixed $connections */
42-
$connections = $_ENV['CONNECTIONS'] ?? false;
43-
if (!is_string($connections)) {
44-
$connections = 'bolt://neo4j:test@neo4j,neo4j://neo4j:test@core1,http://neo4j:test@neo4j';
45-
}
46-
}
47-
foreach (explode(',', $connections) as $uri) {
48-
$psrUri = Uri::create($uri);
49-
if ($psrUri->getScheme() === 'bolt') {
50-
return $psrUri;
51-
}
52-
}
53-
54-
return null;
55-
}
56-
5723
/**
5824
* @throws Exception
5925
*/
6026
public function testValidHostname(): void
6127
{
62-
if ($this->uri === null) {
63-
self::markTestSkipped('No bolt uri provided');
64-
}
28+
$results = BoltDriver::create($this->getUri())
29+
->createSession()
30+
->run('RETURN 1 AS x');
6531

66-
$results = BoltDriver::create($this->uri->__toString())->createSession()->run(<<<'CYPHER'
67-
RETURN 1 AS x
68-
CYPHER);
6932
self::assertEquals(1, $results->first()->get('x'));
7033
}
7134

@@ -74,14 +37,11 @@ public function testValidHostname(): void
7437
*/
7538
public function testValidUrl(): void
7639
{
77-
if ($this->uri === null) {
78-
self::markTestSkipped('No bolt uri provided');
79-
}
40+
$ip = gethostbyname($this->getUri()->getHost());
41+
$results = BoltDriver::create($this->getUri()->withHost($ip)->__toString())
42+
->createSession()
43+
->run('RETURN 1 AS x');
8044

81-
$ip = gethostbyname($this->uri->getHost());
82-
$results = BoltDriver::create($this->uri->withHost($ip)->__toString())->createSession()->run(<<<'CYPHER'
83-
RETURN 1 AS x
84-
CYPHER);
8545
self::assertEquals(1, $results->first()->get('x'));
8646
}
8747

@@ -107,11 +67,7 @@ public function testInvalidSocket(): void
10767

10868
public function testBookmarkUpdates(): void
10969
{
110-
if ($this->uri === null) {
111-
self::markTestSkipped('No bolt uri provided');
112-
}
113-
114-
$session = BoltDriver::create($this->uri->__toString())->createSession();
70+
$session = BoltDriver::create($this->getUri(['bolt', 'neo4j'])->__toString())->createSession();
11571
$bookmark = $session->getLastBookmark();
11672
$this->assertEquals([], $bookmark->values());
11773
$this->assertTrue($bookmark->isEmpty());

tests/Integration/BoltResultIntegrationTest.php

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -13,63 +13,33 @@
1313

1414
namespace Laudis\Neo4j\Tests\Integration;
1515

16-
use Dotenv\Dotenv;
17-
18-
use function explode;
19-
use function is_string;
20-
2116
use Laudis\Neo4j\Authentication\Authenticate;
2217
use Laudis\Neo4j\Bolt\BoltResult;
2318
use Laudis\Neo4j\Bolt\ProtocolFactory;
2419
use Laudis\Neo4j\Bolt\SslConfigurationFactory;
2520
use Laudis\Neo4j\Bolt\SystemWideConnectionFactory;
2621
use Laudis\Neo4j\BoltFactory;
27-
use Laudis\Neo4j\Common\Uri;
2822
use Laudis\Neo4j\Databags\ConnectionRequestData;
2923
use Laudis\Neo4j\Databags\SessionConfiguration;
3024
use Laudis\Neo4j\Databags\SslConfiguration;
3125
use Laudis\Neo4j\Enum\SslMode;
32-
use PHPUnit\Framework\TestCase;
3326

34-
final class BoltResultIntegrationTest extends TestCase
27+
final class BoltResultIntegrationTest extends EnvironmentAwareIntegrationTest
3528
{
36-
/**
37-
* @return array<string, list<string>>
38-
*/
39-
public function buildConnections(): array
29+
public function testIterationLong(): void
4030
{
41-
$connections = $_ENV['CONNECTIONS'] ?? false;
42-
if (!is_string($connections)) {
43-
Dotenv::createImmutable(__DIR__.'/../../')->load();
44-
/** @var string|mixed $connections */
45-
$connections = $_ENV['CONNECTIONS'] ?? false;
46-
if (!is_string($connections)) {
47-
return ['bolt://neo4j:test@neo4j' => ['bolt://neo4j:test@neo4j']];
48-
}
49-
}
50-
51-
$tbr = [];
52-
foreach (explode(',', $connections) as $connection) {
53-
$tbr[$connection] = [$connection];
31+
if ($this->getUri()->getScheme() !== 'bolt') {
32+
self::markTestSkipped('No bolt uri provided');
5433
}
5534

56-
return $tbr;
57-
}
58-
59-
/**
60-
* @dataProvider buildConnections
61-
*/
62-
public function testIterationLong(string $connection): void
63-
{
64-
$uri = Uri::create($connection);
6535
$i = 0;
6636
$factory = new BoltFactory(
6737
SystemWideConnectionFactory::getInstance(),
6838
new ProtocolFactory(),
6939
new SslConfigurationFactory()
7040
);
7141
$connection = $factory->createConnection(
72-
new ConnectionRequestData($uri, Authenticate::fromUrl($uri), 'a/b', new SslConfiguration(SslMode::FROM_URL(), false)),
42+
new ConnectionRequestData($this->getUri(), Authenticate::fromUrl($this->getUri()), 'a/b', new SslConfiguration(SslMode::FROM_URL(), false)),
7343
SessionConfiguration::default()
7444
);
7545

tests/Integration/CacheTest.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@ class CacheTest extends SimpleCacheTest
2020
{
2121
/** @psalm-suppress MissingPropertyType */
2222
protected $skippedTests = [
23-
'testGetInvalidKeys' => 'Handled by dynamic typing',
24-
'testGetMultipleInvalidKeys' => 'Handled by dynamic typing',
25-
'testGetMultipleNoIterable' => 'Handled by dynamic typing',
26-
'testSetInvalidKeys' => 'Handled by dynamic typing',
27-
'testSetMultipleNoIterable' => 'Handled by dynamic typing',
28-
'testHasInvalidKeys' => 'Handled by dynamic typing',
29-
'testDeleteInvalidKeys' => 'Handled by dynamic typing',
30-
'testDeleteMultipleInvalidKeys' => 'Handled by dynamic typing',
31-
'testDeleteMultipleNoIterable' => 'Handled by dynamic typing',
32-
'testSetInvalidTtl' => 'Handled by dynamic typing',
33-
'testSetMultipleInvalidTtl' => 'Handled by dynamic typing',
23+
'testGetInvalidKeys' => 'Handled by strict dynamic typing',
24+
'testGetMultipleInvalidKeys' => 'Handled by strict dynamic typing',
25+
'testGetMultipleNoIterable' => 'Handled by strict dynamic typing',
26+
'testSetInvalidKeys' => 'Handled by strict dynamic typing',
27+
'testSetMultipleNoIterable' => 'Handled by strict dynamic typing',
28+
'testHasInvalidKeys' => 'Handled by strict dynamic typing',
29+
'testDeleteInvalidKeys' => 'Handled by strict dynamic typing',
30+
'testDeleteMultipleInvalidKeys' => 'Handled by strict dynamic typing',
31+
'testDeleteMultipleNoIterable' => 'Handled by strict dynamic typing',
32+
'testSetInvalidTtl' => 'Handled by strict dynamic typing',
33+
'testSetMultipleInvalidTtl' => 'Handled by strict dynamic typing',
3434
];
3535

3636
public function createSimpleCache(): Cache

tests/Integration/ClientBuilderTest.php

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

0 commit comments

Comments
 (0)