Skip to content

Commit 4ff700f

Browse files
exaby73transistive
authored andcommitted
test: Add test for priority
1 parent a83fd47 commit 4ff700f

File tree

3 files changed

+62
-1
lines changed

3 files changed

+62
-1
lines changed

tests/App/config/ci/default.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
parameters:
22
neo4j.dsn.badname: bolt://localhostt
33
neo4j.dsn.test: neo4j://neo4j:testtest@localhost
4+
neo4j.dsn.auth: neo4j://localhost

tests/App/config/default.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ parameters:
66
neo4j.dsn.badname: bolt://localhost
77
neo4j.dsn.secret: neo4j://neo4j:secret@localhost:7688
88
neo4j.dsn.test: neo4j://neo4j:testtest@neo4j
9+
neo4j.dsn.auth: neo4j://neo4j
910
neo4j.dsn.simple: bolt://test:test@localhost
1011

1112
neo4j:
@@ -48,3 +49,10 @@ neo4j:
4849

4950
- alias: neo4j-test
5051
dsn: "%neo4j.dsn.test%"
52+
53+
- alias: neo4j-auth
54+
dsn: "%neo4j.dsn.auth%"
55+
authentication:
56+
type: basic
57+
username: neo4j
58+
password: testtest

tests/Functional/IntegrationTest.php

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,17 @@
77
namespace Neo4j\Neo4jBundle\Tests\Functional;
88

99
use Laudis\Neo4j\Client;
10+
use Laudis\Neo4j\Common\DriverSetupManager;
1011
use Laudis\Neo4j\Common\SingleThreadedSemaphore;
1112
use Laudis\Neo4j\Contracts\ClientInterface;
1213
use Laudis\Neo4j\Contracts\DriverInterface;
1314
use Laudis\Neo4j\Databags\ConnectionRequestData;
15+
use Laudis\Neo4j\Databags\DriverSetup;
1416
use Laudis\Neo4j\Databags\SslConfiguration;
1517
use Laudis\Neo4j\Enum\SslMode;
1618
use Laudis\Neo4j\Neo4j\Neo4jConnectionPool;
1719
use Laudis\Neo4j\Neo4j\Neo4jDriver;
20+
use Neo4j\Neo4jBundle\SymfonyClient;
1821
use Neo4j\Neo4jBundle\Tests\App\TestKernel;
1922
use Psr\Http\Message\UriInterface;
2023
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
@@ -100,6 +103,31 @@ public function testDsn(): void
100103
$client->getDriver('neo4j_undefined_configs');
101104
}
102105

106+
public function testDriverAuthentication(): void
107+
{
108+
static::bootKernel();
109+
$container = static::getContainer();
110+
111+
/**
112+
* @var ClientInterface $client
113+
*/
114+
$client = $container->get('neo4j.client');
115+
/** @var Neo4jDriver $driver */
116+
$driver = $client->getDriver('neo4j-auth');
117+
/** @var Neo4jConnectionPool $pool */
118+
$pool = $this->getPrivateProperty($driver, 'pool');
119+
/** @var ConnectionRequestData $data */
120+
$data = $this->getPrivateProperty($pool, 'data');
121+
$auth = $data->getAuth();
122+
/** @var string $username */
123+
$username = $this->getPrivateProperty($auth, 'username');
124+
/** @var string $password */
125+
$password = $this->getPrivateProperty($auth, 'password');
126+
127+
$this->assertSame($username, 'neo4j');
128+
$this->assertSame($password, 'testtest');
129+
}
130+
103131
public function testDefaultDriverConfig(): void
104132
{
105133
static::bootKernel();
@@ -153,7 +181,7 @@ public function testDefaultSessionConfig(): void
153181
$this->assertSame($sessionConfig->getFetchSize(), 999);
154182
}
155183

156-
public function testDefaultTrasactionConfig(): void
184+
public function testDefaultTransactionConfig(): void
157185
{
158186
static::bootKernel();
159187
$container = static::getContainer();
@@ -169,6 +197,30 @@ public function testDefaultTrasactionConfig(): void
169197
$this->assertSame($transactionConfig->getTimeout(), 40.0);
170198
}
171199

200+
public function testPriority(): void
201+
{
202+
static::bootKernel();
203+
$container = static::getContainer();
204+
205+
/**
206+
* @var ClientInterface $client
207+
*/
208+
$client = $container->get('neo4j.client');
209+
/** @var Client $innerClient */
210+
$innerClient = $this->getPrivateProperty($client, 'client');
211+
/** @var DriverSetupManager $drivers */
212+
$drivers = $this->getPrivateProperty($innerClient, 'driverSetups');
213+
/** @var array<\SplPriorityQueue<int, DriverSetup>> $fallbackDriverQueue */
214+
$driverSetups = $this->getPrivateProperty($drivers, 'driverSetups');
215+
/** @var \SplPriorityQueue<int, DriverSetup> $fallbackDriverQueue */
216+
$fallbackDriverQueue = $driverSetups['neo4j-fallback-mechanism'];
217+
$fallbackDriverQueue->setExtractFlags(\SplPriorityQueue::EXTR_BOTH);
218+
/** @var array{data: DriverSetup, priority: int} $extractedValue */
219+
$extractedValue = $fallbackDriverQueue->extract();
220+
221+
$this->assertSame($extractedValue['priority'], 1000);
222+
}
223+
172224
/**
173225
* @template T
174226
*

0 commit comments

Comments
 (0)