Skip to content

Commit

Permalink
test: Add tests for new aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
exaby73 committed Nov 6, 2024
1 parent f889710 commit 1ec5a1c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/DependencyInjection/Neo4jExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,17 @@ public function load(array $configs, ContainerBuilder $container): ContainerBuil
(new Definition(DriverInterface::class))
->setFactory([new Reference('neo4j.client'), 'getDriver'])
->setArgument(0, $driverConfig['alias'])
);
)
->setPublic(true);

$container
->setDefinition(
'neo4j.session.'.$driverConfig['alias'],
(new Definition(SessionInterface::class))
->setFactory([new Reference('neo4j.driver.'.$driverConfig['alias']), 'createSession'])
->setShared(false)
);
)
->setPublic(true);
}

$enabledProfiles = [];
Expand Down
4 changes: 1 addition & 3 deletions tests/App/Controller/TestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
use Laudis\Neo4j\Contracts\ClientInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Profiler\Profiler;
use Symfony\Component\Stopwatch\Stopwatch;

class TestController extends AbstractController
{
Expand All @@ -15,7 +13,7 @@ public function __construct(
) {
}

public function __invoke(Profiler $profiler, Stopwatch $stopwatch): Response
public function __invoke(): Response
{
// Successful statement
$this->client->run('MATCH (n {foo: $bar}) RETURN n', ['bar' => 'baz']);
Expand Down
12 changes: 12 additions & 0 deletions tests/Functional/IntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,18 @@ public function testDefaultTransactionConfig(): void
$this->assertSame($transactionConfig->getTimeout(), 40.0);
}

public function testDriverAndSessionTags(): void
{
static::bootKernel();
$container = static::getContainer();

$this->assertTrue($container->has('neo4j.driver.neo4j-simple'));
$this->assertTrue($container->has('neo4j.driver.neo4j-test'));

$this->assertTrue($container->has('neo4j.session.neo4j-simple'));
$this->assertTrue($container->has('neo4j.session.neo4j-test'));
}

public function testPriority(): void
{
static::bootKernel();
Expand Down

0 comments on commit 1ec5a1c

Please sign in to comment.