Skip to content

Commit 9c5d659

Browse files
authored
Make sure we configure the bundle with a dsn (#47)
* Make sure we configure the bundle with a dsn * Cs * cs * Update Neo4jExtension.php
1 parent 800a060 commit 9c5d659

File tree

4 files changed

+28
-1
lines changed

4 files changed

+28
-1
lines changed

DependencyInjection/Configuration.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ public function getConfigTreeBuilder()
9090
->integerNode('port')->end()
9191
->scalarNode('username')->defaultValue('neo4j')->end()
9292
->scalarNode('password')->defaultValue('neo4j')->end()
93+
->scalarNode('dsn')->defaultNull()->end()
9394
->end()
9495
->end()
9596
->end();

DependencyInjection/Neo4jExtension.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,10 @@ private function handleConnections(array &$config, ContainerBuilder $container):
193193
*/
194194
private function getUrl(array $config): string
195195
{
196+
if (null !== $config['dsn']) {
197+
return $config['dsn'];
198+
}
199+
196200
return sprintf(
197201
'%s://%s:%s@%s:%d',
198202
$config['scheme'],

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,11 @@ neo4j:
7575
second_connection:
7676
username: foo
7777
password: bar
78+
third_connection:
79+
dsn: 'bolt://foo:bar@localhost:7687'
7880
clients:
7981
default:
80-
connections: [default, second_connection]
82+
connections: [default, second_connection, third_connection]
8183
other_client:
8284
connections: [second_connection]
8385
foobar: ~ # foobar client will have the "default" connection

Tests/Unit/DependencyInjection/Neo4jExtensionTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,24 @@ protected function getContainerExtensions()
4747
new Neo4jExtension(),
4848
];
4949
}
50+
51+
public function testDefaultDsn()
52+
{
53+
$this->setParameter('kernel.debug', false);
54+
$this->load();
55+
$this->assertContainerBuilderHasServiceDefinitionWithArgument('neo4j.connection.default', 1, 'bolt://neo4j:neo4j@localhost:7474');
56+
}
57+
58+
public function testDsn()
59+
{
60+
$this->setParameter('kernel.debug', false);
61+
$config = ['connections' => [
62+
'default' => [
63+
'dsn' => 'bolt://foo:bar@localhost:7687',
64+
],
65+
]];
66+
67+
$this->load($config);
68+
$this->assertContainerBuilderHasServiceDefinitionWithArgument('neo4j.connection.default', 1, 'bolt://foo:bar@localhost:7687');
69+
}
5070
}

0 commit comments

Comments
 (0)