13
13
14
14
namespace Laudis \Neo4j \Tests \Integration ;
15
15
16
+ use Dotenv \Dotenv ;
16
17
use function explode ;
17
- use function getenv ;
18
18
use Laudis \Neo4j \ClientBuilder ;
19
19
use Laudis \Neo4j \Common \Uri ;
20
20
use PHPUnit \Framework \TestCase ;
21
21
22
22
final class ClientBuilderTest extends TestCase
23
23
{
24
- private function getBoltUri (): string
24
+ private function getBoltUri (): ? string
25
25
{
26
- foreach (explode (', ' , (string ) getenv ('NEO4J_CONNECTIONS ' )) as $ uri ) {
26
+ /** @var string|mixed $connections */
27
+ $ connections = $ _ENV ['NEO4J_CONNECTIONS ' ] ?? false ;
28
+ if (!is_string ($ connections )) {
29
+ Dotenv::createImmutable (__DIR__ . '/../../ ' )->load ();
30
+ /** @var string|mixed $connections */
31
+ $ connections = $ _ENV ['NEO4J_CONNECTIONS ' ] ?? false ;
32
+ if (!is_string ($ connections )) {
33
+ $ connections = '' ;
34
+ }
35
+ }
36
+ foreach (explode (', ' , $ connections ) as $ uri ) {
27
37
$ psrUri = Uri::create ($ uri );
28
38
if ($ psrUri ->getScheme () === 'bolt ' ) {
29
39
return $ psrUri ->__toString ();
30
40
}
31
41
}
32
42
33
- return ' bolt://neo4j:test@neo4j:7687 ' ;
43
+ return null ;
34
44
}
35
45
36
46
public function testBoltSetupWithScheme (): void
37
47
{
48
+ if ($ this ->getBoltUri () === null ) {
49
+ self ::markTestSkipped ('No bolt uri provided ' );
50
+ }
51
+
38
52
$ client = ClientBuilder::create ()->addBoltConnection ('bolt ' , $ this ->getBoltUri ())->build ();
39
53
$ tsx = $ client ->beginTransaction ();
40
54
self ::assertTrue (true );
@@ -43,6 +57,10 @@ public function testBoltSetupWithScheme(): void
43
57
44
58
public function testBoltSetupWithoutPort (): void
45
59
{
60
+ if ($ this ->getBoltUri () === null ) {
61
+ self ::markTestSkipped ('No bolt uri provided ' );
62
+ }
63
+
46
64
$ client = ClientBuilder::create ()->addBoltConnection ('bolt ' , $ this ->getBoltUri ())->build ();
47
65
$ tsx = $ client ->beginTransaction ();
48
66
self ::assertTrue (true );
@@ -51,6 +69,10 @@ public function testBoltSetupWithoutPort(): void
51
69
52
70
public function testBoltSetupWrongScheme (): void
53
71
{
72
+ if ($ this ->getBoltUri () === null ) {
73
+ self ::markTestSkipped ('No bolt uri provided ' );
74
+ }
75
+
54
76
$ client = ClientBuilder::create ()->addBoltConnection ('bolt ' , $ this ->getBoltUri ())->build ();
55
77
$ tsx = $ client ->beginTransaction ();
56
78
self ::assertTrue (true );
0 commit comments