1
1
<?php
2
2
3
+ /** @noinspection PhpInternalEntityUsedInspection */
4
+
3
5
declare (strict_types=1 );
4
6
5
7
namespace Neo4j \Neo4jBundle \Tests \Functional ;
6
8
9
+ use Laudis \Neo4j \Client ;
10
+ use Laudis \Neo4j \Common \SingleThreadedSemaphore ;
7
11
use Laudis \Neo4j \Contracts \ClientInterface ;
8
12
use 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 ;
9
17
use Laudis \Neo4j \Neo4j \Neo4jDriver ;
10
18
use Neo4j \Neo4jBundle \Tests \App \TestKernel ;
11
19
use Psr \Http \Message \UriInterface ;
@@ -67,12 +75,10 @@ public function testDefaultDsn(): void
67
75
* @var Neo4jDriver $driver
68
76
*/
69
77
$ driver = $ client ->getDriver ('default ' );
70
- $ reflection = new \ReflectionClass ($ driver );
71
- $ property = $ reflection ->getProperty ('parsedUrl ' );
72
78
/**
73
79
* @var UriInterface $uri
74
80
*/
75
- $ uri = $ property -> getValue ($ driver );
81
+ $ uri = $ this -> getPrivateProperty ($ driver, ' parsedUrl ' );
76
82
77
83
$ this ->assertSame ($ uri ->getScheme (), 'neo4j ' );
78
84
}
@@ -93,4 +99,88 @@ public function testDsn(): void
93
99
$ client = $ container ->get ('neo4j.client ' );
94
100
$ client ->getDriver ('neo4j_undefined_configs ' );
95
101
}
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
+ }
96
186
}
0 commit comments