-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
15f57c0
commit fece01b
Showing
3 changed files
with
108 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the Laudis Neo4j package. | ||
* | ||
* (c) Laudis technologies <http://laudis.tech> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Laudis\Neo4j\Tests\Integration; | ||
|
||
use Exception; | ||
use Laudis\Neo4j\Databags\Statement; | ||
use Laudis\Neo4j\Exception\Neo4jException; | ||
use Laudis\Neo4j\Network\Bolt\BoltDriver; | ||
use Laudis\Neo4j\Network\Bolt\BoltInjections; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* @psalm-import-type ParsedUrl from BoltDriver | ||
*/ | ||
final class BoltDriverIntegration extends TestCase | ||
{ | ||
/** | ||
* @throws Exception | ||
*/ | ||
public function testValidHostname(): void | ||
{ | ||
/** @var ParsedUrl $parsedUrl */ | ||
$parsedUrl = parse_url('bolt://neo4j:test@neo4j-42'); | ||
$driver = new BoltDriver($parsedUrl, BoltInjections::create()); | ||
$session = $driver->aquireSession(); | ||
$results = $session->run([new Statement(<<<'CYPHER' | ||
RETURN 1 AS x | ||
CYPHER, [])]); | ||
self::assertEquals(1, $results->first()->first()->get('x')); | ||
} | ||
|
||
/** | ||
* @throws Exception | ||
*/ | ||
public function testValidUrl(): void | ||
{ | ||
$ip = gethostbyname('neo4j-42'); | ||
/** @var ParsedUrl $parsedUrl */ | ||
$parsedUrl = parse_url('bolt://neo4j:test@'.$ip); | ||
$driver = new BoltDriver($parsedUrl, BoltInjections::create()); | ||
$session = $driver->aquireSession(); | ||
$results = $session->run([new Statement(<<<'CYPHER' | ||
RETURN 1 AS x | ||
CYPHER, [])]); | ||
self::assertEquals(1, $results->first()->first()->get('x')); | ||
} | ||
|
||
/** | ||
* @throws Exception | ||
*/ | ||
public function testInvalid(): void | ||
{ | ||
/** @var ParsedUrl $parsedUrl */ | ||
$parsedUrl = parse_url('bolt://neo4j:[email protected]'); | ||
$driver = new BoltDriver($parsedUrl, BoltInjections::create()); | ||
$this->expectException(Neo4jException::class); | ||
$driver->aquireSession(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the Laudis Neo4j package. | ||
* | ||
* (c) Laudis technologies <http://laudis.tech> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Laudis\Neo4j\Tests\Unit; | ||
|
||
use Laudis\Neo4j\Network\Bolt\BoltInjections; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
final class BoltInjectionsTest extends TestCase | ||
{ | ||
public function testConstruct(): void | ||
{ | ||
$injections = BoltInjections::create('test'); | ||
self::assertEquals('test', $injections->database()); | ||
$injections = new BoltInjections('abc'); | ||
self::assertEquals('abc', $injections->database()); | ||
} | ||
|
||
public function testWithDatabase(): void | ||
{ | ||
$injections = new BoltInjections('abc'); | ||
self::assertEquals('test', $injections->withDatabase('test')->database()); | ||
} | ||
} |