23
23
use PHPUnit \Framework \TestCase ;
24
24
use Psr \Log \LoggerInterface ;
25
25
use Psr \Log \LogLevel ;
26
+ use RuntimeException ;
26
27
27
28
abstract class EnvironmentAwareIntegrationTest extends TestCase
28
29
{
29
- private static bool $ isSetUp = false ;
30
- protected static Session $ session ;
31
- protected static Driver $ driver ;
32
- protected static Uri $ uri ;
33
- protected static Neo4jLogger $ logger ;
30
+ protected Session $ session ;
31
+ protected Driver $ driver ;
32
+ protected Uri $ uri ;
33
+ protected Neo4jLogger $ logger ;
34
34
35
35
public function setUp (): void
36
36
{
@@ -41,17 +41,16 @@ public function setUp(): void
41
41
$ connection = 'bolt://localhost ' ;
42
42
}
43
43
44
- if (self ::$ isSetUp ) {
45
- return ;
46
- }
47
-
48
44
/** @noinspection PhpUnhandledExceptionInspection */
49
45
$ conf = DriverConfiguration::default ()->withLogger (LogLevel::DEBUG , $ this ->createMock (LoggerInterface::class));
50
- self ::$ logger = $ conf ->getLogger ();
51
- self ::$ uri = Uri::create ($ connection );
52
- self ::$ driver = Driver::create (self ::$ uri , $ conf );
53
- self ::$ session = self ::$ driver ->createSession ();
54
- self ::$ isSetUp = true ;
46
+ $ logger = $ conf ->getLogger ();
47
+ if ($ logger === null ) {
48
+ throw new RuntimeException ('Logger not set ' );
49
+ }
50
+ $ this ->logger = $ logger ;
51
+ $ this ->uri = Uri::create ($ connection );
52
+ $ this ->driver = Driver::create ($ this ->uri , $ conf );
53
+ $ this ->session = $ this ->driver ->createSession ();
55
54
}
56
55
57
56
/**
@@ -61,7 +60,7 @@ public function getSession(array|string|null $forceScheme = null): Session
61
60
{
62
61
$ this ->skipUnsupportedScheme ($ forceScheme );
63
62
64
- return self :: $ session ;
63
+ return $ this -> session ;
65
64
}
66
65
67
66
/**
@@ -71,7 +70,7 @@ public function getUri(array|string|null $forceScheme = null): Uri
71
70
{
72
71
$ this ->skipUnsupportedScheme ($ forceScheme );
73
72
74
- return self :: $ uri ;
73
+ return $ this -> uri ;
75
74
}
76
75
77
76
/**
@@ -94,7 +93,7 @@ private function skipUnsupportedScheme(array|string|null $forceScheme): void
94
93
$ options [] = $ scheme .'+ssc ' ;
95
94
}
96
95
97
- if (!in_array (self :: $ uri ->getScheme (), $ options )) {
96
+ if (!in_array ($ this -> uri ->getScheme (), $ options )) {
98
97
/** @psalm-suppress MixedArgumentTypeCoercion */
99
98
$ this ->markTestSkipped (sprintf (
100
99
'Connection only for types: "%s" ' ,
@@ -110,11 +109,11 @@ protected function getDriver(array|string|null $forceScheme = null): Driver
110
109
{
111
110
$ this ->skipUnsupportedScheme ($ forceScheme );
112
111
113
- return self :: $ driver ;
112
+ return $ this -> driver ;
114
113
}
115
114
116
115
protected function getNeo4jLogger (): Neo4jLogger
117
116
{
118
- return self :: $ logger ;
117
+ return $ this -> logger ;
119
118
}
120
119
}
0 commit comments