Skip to content

Commit

Permalink
Tests: add basic test for dbal extension with minimal config
Browse files Browse the repository at this point in the history
  • Loading branch information
f3l1x committed Dec 6, 2024
1 parent d7dbf9b commit 503cfb9
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tests/Cases/DI/DbalExtension.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php declare(strict_types = 1);

namespace Tests\Cases\DI;

use Contributte\Tester\Toolkit;
use Contributte\Tester\Utils\ContainerBuilder;
use Contributte\Tester\Utils\Neonkit;
use Doctrine\DBAL\Connection;
use Nette\DI\Compiler;
use Nettrine\DBAL\DI\DbalExtension;
use Tester\Assert;

require_once __DIR__ . '/../../bootstrap.php';

// Minimal config
Toolkit::test(function (): void {
$container = ContainerBuilder::of()
->withCompiler(static function (Compiler $compiler): void {
$compiler->addExtension('nettrine.dbal', new DbalExtension());
$compiler->addConfig(Neonkit::load(
<<<'NEON'
nettrine.dbal:
connections:
default:
driver: pdo_sqlite
password: test
user: test
path: ":memory:"
NEON
));
})->build();

Assert::type(Connection::class, $container->getByName('nettrine.dbal.connections.default.connection'));
});

0 comments on commit 503cfb9

Please sign in to comment.