Skip to content
This repository was archived by the owner on Dec 1, 2021. It is now read-only.

Commit c6384ca

Browse files
authored
Merge pull request #103 from Nyholm/patch-phpunit
Allow to specify neo4j credentials in phpunit.xml
2 parents 1ed8f77 + d4a7d36 commit c6384ca

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

tests/Integration/IntegrationTestCase.php

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,31 @@ class IntegrationTestCase extends \PHPUnit_Framework_TestCase
2222

2323
public function setUp()
2424
{
25+
$httpUri = 'http://localhost:7474';
26+
if (isset($_ENV['NEO4J_USER'])) {
27+
$httpUri = sprintf(
28+
'%s://%s:%s@%s:%s',
29+
getenv('NEO4J_SCHEMA'),
30+
getenv('NEO4J_USER'),
31+
getenv('NEO4J_PASSWORD'),
32+
getenv('NEO4J_HOST'),
33+
getenv('NEO4J_PORT')
34+
);
35+
}
36+
37+
$boltUrl = 'bolt://localhost';
38+
if (isset($_ENV['NEO4J_USER'])) {
39+
$boltUrl = sprintf(
40+
'bolt://%s:%s@%',
41+
getenv('NEO4J_USER'),
42+
getenv('NEO4J_PASSWORD'),
43+
getenv('NEO4J_HOST')
44+
);
45+
}
46+
2547
$this->client = ClientBuilder::create()
26-
->addConnection('http', 'http://localhost:7474')
27-
->addConnection('bolt', 'bolt://localhost')
48+
->addConnection('http', $httpUri)
49+
->addConnection('bolt', $boltUrl)
2850
->build();
2951
}
3052

0 commit comments

Comments
 (0)