2323use PHPUnit \Framework \TestCase ;
2424use Psr \Log \LoggerInterface ;
2525use Psr \Log \LogLevel ;
26+ use RuntimeException ;
2627
2728abstract class EnvironmentAwareIntegrationTest extends TestCase
2829{
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 ;
3434
3535 public function setUp (): void
3636 {
@@ -41,17 +41,16 @@ public function setUp(): void
4141 $ connection = 'bolt://localhost ' ;
4242 }
4343
44- if (self ::$ isSetUp ) {
45- return ;
46- }
47-
4844 /** @noinspection PhpUnhandledExceptionInspection */
4945 $ 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 ();
5554 }
5655
5756 /**
@@ -61,7 +60,7 @@ public function getSession(array|string|null $forceScheme = null): Session
6160 {
6261 $ this ->skipUnsupportedScheme ($ forceScheme );
6362
64- return self :: $ session ;
63+ return $ this -> session ;
6564 }
6665
6766 /**
@@ -71,7 +70,7 @@ public function getUri(array|string|null $forceScheme = null): Uri
7170 {
7271 $ this ->skipUnsupportedScheme ($ forceScheme );
7372
74- return self :: $ uri ;
73+ return $ this -> uri ;
7574 }
7675
7776 /**
@@ -94,7 +93,7 @@ private function skipUnsupportedScheme(array|string|null $forceScheme): void
9493 $ options [] = $ scheme .'+ssc ' ;
9594 }
9695
97- if (!in_array (self :: $ uri ->getScheme (), $ options )) {
96+ if (!in_array ($ this -> uri ->getScheme (), $ options )) {
9897 /** @psalm-suppress MixedArgumentTypeCoercion */
9998 $ this ->markTestSkipped (sprintf (
10099 'Connection only for types: "%s" ' ,
@@ -110,11 +109,11 @@ protected function getDriver(array|string|null $forceScheme = null): Driver
110109 {
111110 $ this ->skipUnsupportedScheme ($ forceScheme );
112111
113- return self :: $ driver ;
112+ return $ this -> driver ;
114113 }
115114
116115 protected function getNeo4jLogger (): Neo4jLogger
117116 {
118- return self :: $ logger ;
117+ return $ this -> logger ;
119118 }
120119}
0 commit comments