dama/doctrine-test-bundle
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
doctrine/dbal | 4.0.2 | - | MIT | prod dev | |
doctrine/doctrine-bundle | 2.12.0 | - | MIT | prod | |
psr/cache | 3.0.0 | 6.01 kB | MIT | prod dev | |
symfony/cache | v7.0.7 | - | MIT | prod dev | |
symfony/framework-bundle | v7.0.7 | - | MIT | prod | |
symfony/process | v7.0.7 | - | MIT | prod dev |
The dama/doctrine-test-bundle is a Symfony bundle designed to isolate Doctrine database tests and improve the performance of their execution. This is achieved by using a StaticDriver
that wraps your original Driver
class and maintains a static database connection in the current PHP process. It begins a transaction before every test case and rolls it back after every test case for all configured DBAL connections. This eliminates the necessity of rebuilding the schema or re-inserting fixtures before every test case, which can significantly boost performance. Along with enhancing test speeds, it also improves memory usage, especially for tests that boot kernels and use Doctrine entities.
To leverage the benefits of dama/doctrine-test-bundle, you need to install and integrate it into your application. The first step is to install the bundle using Composer. Below is an example of the command that can be executed in your command line:
composer require --dev dama/doctrine-test-bundle
Next, you need to enable the bundle for your test environment in your AppKernel.php
file. Here's a general PHP code snippet for the same:
if (in_array($env, ['dev', 'test'])) {
...
if ($env === 'test') {
$bundles[] = new DAMA\DoctrineTestBundle\DAMADoctrineTestBundle();
}
}
The dama/doctrine-test-bundle also includes a PHPUnit extension that should be added to your PHPUnit XML configuration. Depending on your PHPUnit version, the line may slightly vary. The general structure should appear as follows for PHPUnit 8 or 9:
<phpunit>
...
<extensions>
<extension class="DAMA\DoctrineTestBundle\PHPUnit\PHPUnitExtension" />
</extensions>
</phpunit>
And for PHPUnit 10+:
<phpunit>
...
<extensions>
<bootstrap class="DAMA\DoctrineTestBundle\PHPUnit\PHPUnitExtension" />
</extensions>
</phpunit>
The most comprehensive source of documentation for the dama/doctrine-test-bundle is available on its GitHub page. This includes example usage, installation instructions, how to use the bundle with PHPUnit & Behat, configuration details, and troubleshooting tips. Sample usage and test cases can be found under the tests
directory in the bundle's GitHub repository. You can access it here.