11<?php
22
3+ /** @noinspection PhpInternalEntityUsedInspection */
4+
35declare (strict_types=1 );
46
57namespace Neo4j \Neo4jBundle \Tests \Functional ;
68
9+ use Laudis \Neo4j \Client ;
10+ use Laudis \Neo4j \Common \SingleThreadedSemaphore ;
711use Laudis \Neo4j \Contracts \ClientInterface ;
812use Laudis \Neo4j \Contracts \DriverInterface ;
13+ use Laudis \Neo4j \Databags \ConnectionRequestData ;
14+ use Laudis \Neo4j \Databags \SslConfiguration ;
15+ use Laudis \Neo4j \Enum \SslMode ;
16+ use Laudis \Neo4j \Neo4j \Neo4jConnectionPool ;
917use Laudis \Neo4j \Neo4j \Neo4jDriver ;
1018use Neo4j \Neo4jBundle \Tests \App \TestKernel ;
1119use Psr \Http \Message \UriInterface ;
@@ -67,12 +75,10 @@ public function testDefaultDsn(): void
6775 * @var Neo4jDriver $driver
6876 */
6977 $ driver = $ client ->getDriver ('default ' );
70- $ reflection = new \ReflectionClass ($ driver );
71- $ property = $ reflection ->getProperty ('parsedUrl ' );
7278 /**
7379 * @var UriInterface $uri
7480 */
75- $ uri = $ property -> getValue ($ driver );
81+ $ uri = $ this -> getPrivateProperty ($ driver, ' parsedUrl ' );
7682
7783 $ this ->assertSame ($ uri ->getScheme (), 'neo4j ' );
7884 }
@@ -93,4 +99,88 @@ public function testDsn(): void
9399 $ client = $ container ->get ('neo4j.client ' );
94100 $ client ->getDriver ('neo4j_undefined_configs ' );
95101 }
102+
103+ public function testDefaultDriverConfig (): void
104+ {
105+ static ::bootKernel ();
106+ $ container = static ::getContainer ();
107+
108+ /**
109+ * @var ClientInterface $client
110+ */
111+ $ client = $ container ->get ('neo4j.client ' );
112+ /** @var Neo4jDriver $driver */
113+ $ driver = $ client ->getDriver ('default ' );
114+ /** @var Neo4jConnectionPool $pool */
115+ $ pool = $ this ->getPrivateProperty ($ driver , 'pool ' );
116+ /** @var SingleThreadedSemaphore $semaphore */
117+ $ semaphore = $ this ->getPrivateProperty ($ pool , 'semaphore ' );
118+ /** @var int $max */
119+ $ max = $ this ->getPrivateProperty ($ semaphore , 'max ' );
120+
121+ // default_driver_config.pool_size
122+ $ this ->assertSame ($ max , 256 );
123+
124+ /** @var ConnectionRequestData $data */
125+ $ data = $ this ->getPrivateProperty ($ pool , 'data ' );
126+
127+ $ this ->assertSame ($ data ->getUserAgent (), 'Neo4j Symfony Bundle/testing ' );
128+
129+ /** @var SslConfiguration $sslConfig */
130+ $ sslConfig = $ this ->getPrivateProperty ($ data , 'config ' );
131+ /** @var SslMode $sslMode */
132+ $ sslMode = $ this ->getPrivateProperty ($ sslConfig , 'mode ' );
133+ /** @var bool $verifyPeer */
134+ $ verifyPeer = $ this ->getPrivateProperty ($ sslConfig , 'verifyPeer ' );
135+
136+ $ this ->assertSame ($ sslMode , SslMode::DISABLE ());
137+ $ this ->assertFalse ($ verifyPeer );
138+ }
139+
140+ public function testDefaultSessionConfig (): void
141+ {
142+ static ::bootKernel ();
143+ $ container = static ::getContainer ();
144+
145+ /**
146+ * @var ClientInterface $client
147+ */
148+ $ client = $ container ->get ('neo4j.client ' );
149+ /** @var Client $innerClient */
150+ $ innerClient = $ this ->getPrivateProperty ($ client , 'client ' );
151+ $ sessionConfig = $ innerClient ->getDefaultSessionConfiguration ();
152+
153+ $ this ->assertSame ($ sessionConfig ->getFetchSize (), 999 );
154+ }
155+
156+ public function testDefaultTrasactionConfig (): void
157+ {
158+ static ::bootKernel ();
159+ $ container = static ::getContainer ();
160+
161+ /**
162+ * @var ClientInterface $client
163+ */
164+ $ client = $ container ->get ('neo4j.client ' );
165+ /** @var Client $innerClient */
166+ $ innerClient = $ this ->getPrivateProperty ($ client , 'client ' );
167+ $ transactionConfig = $ innerClient ->getDefaultTransactionConfiguration ();
168+
169+ $ this ->assertSame ($ transactionConfig ->getTimeout (), 40.0 );
170+ }
171+
172+ /**
173+ * @template T
174+ *
175+ * @return T
176+ *
177+ * @noinspection PhpDocMissingThrowsInspection
178+ */
179+ private function getPrivateProperty (object $ object , string $ property ): mixed
180+ {
181+ $ reflection = new \ReflectionClass ($ object );
182+ $ property = $ reflection ->getProperty ($ property );
183+
184+ return $ property ->getValue ($ object );
185+ }
96186}
0 commit comments