PHPackages                             dama/doctrine-test-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. dama/doctrine-test-bundle

ActiveSymfony-bundle[Testing &amp; Quality](/categories/testing)

dama/doctrine-test-bundle
=========================

Symfony bundle to isolate doctrine database tests and improve test performance

v8.6.0(3mo ago)1.2k37.2M—7.2%62[6 issues](https://github.com/dmaicher/doctrine-test-bundle/issues)20MITPHPPHP &gt;= 8.2

Since Mar 19Pushed 2mo ago8 watchersCompare

[ Source](https://github.com/dmaicher/doctrine-test-bundle)[ Packagist](https://packagist.org/packages/dama/doctrine-test-bundle)[ RSS](/packages/dama-doctrine-test-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (11)Versions (78)Used By (20)

[![PHP Version](https://camo.githubusercontent.com/ef47336cd5414a0b4973a513eac34446a112c30c900b4b9a79dcb36529866e71/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f64616d612f646f637472696e652d746573742d62756e646c65)](https://packagist.org/packages/dama/doctrine-test-bundle)[![Stable release](https://camo.githubusercontent.com/b467bf6f2d2a78fb25c6d81ce9fcb7610d16407abb05fa82e7256d91b99bc3cb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f64616d612f646f637472696e652d746573742d62756e646c65)](https://packagist.org/packages/dama/doctrine-test-bundle)

### What does it do? 😊

[](#what-does-it-do-blush)

This bundle provides features that help you run your Symfony-framework-based App's testsuite more efficiently with isolated tests.

It provides a `StaticDriver` that will wrap your originally configured `Driver` class (like `DBAL\Driver\PDOMysql\Driver`) and keeps a database connection statically in the current php process.

With the help of a PHPUnit extension class it will begin a transaction before every testcase and roll it back again after the test finished for all configured DBAL connections. This results in a performance boost as there is no need to rebuild the schema, import a backup SQL dump or re-insert fixtures before every testcase. As long as you avoid issuing DDL queries that might result in implicit transaction commits (Like `ALTER TABLE`, `DROP TABLE` etc; see [https://wiki.postgresql.org/wiki/Transactional\_DDL\_in\_PostgreSQL:\_A\_Competitive\_Analysis](https://wiki.postgresql.org/wiki/Transactional_DDL_in_PostgreSQL:_A_Competitive_Analysis)) your tests will be isolated and all see the same database state.

It also includes a `Psr6StaticArrayCache` that will be automatically configured as meta data &amp; query cache for all EntityManagers. This improved the speed and memory usage for my testsuites dramatically! This is especially beneficial if you have a lot of tests that boot kernels (like Controller tests or ContainerAware tests) and use Doctrine entities.

### How to install and use this Bundle?

[](#how-to-install-and-use-this-bundle)

1. install via composer

```
composer require --dev dama/doctrine-test-bundle
```

2. If you're not using Flex, enable the bundle by adding the class to bundles.php

```
