PHPackages                             hgraca/doctrine-test-db-regeneration-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. hgraca/doctrine-test-db-regeneration-bundle

AbandonedArchivedLibrary[Testing &amp; Quality](/categories/testing)

hgraca/doctrine-test-db-regeneration-bundle
===========================================

Symfony 2/3/4 bundle to generate the test DB (if needed) for every test suite run or test method run.

v1.1.2(7y ago)46.6k↓37.5%2MITPHPPHP ^7.1

Since Mar 5Pushed 7y ago1 watchersCompare

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

READMEChangelog (6)Dependencies (12)Versions (7)Used By (0)

Hgraca \\ DoctrineTestDbRegenerationBundle
==========================================

[](#hgraca--doctrinetestdbregenerationbundle)

[![Author](https://camo.githubusercontent.com/e80528a6fbd7a1766b221b1a32d700b339f6a1992a8e0a1f602d24c256c74d66/687474703a2f2f696d672e736869656c64732e696f2f62616467652f617574686f722d406867726163612d626c75652e7376673f7374796c653d666c61742d737175617265)](https://www.herbertograca.com)[![Software License](https://camo.githubusercontent.com/942e017bf0672002dd32a857c95d66f28c5900ab541838c6c664442516309c8a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Latest Version](https://camo.githubusercontent.com/4e9eacd7d895d3c8580bf58b7189ae10dc17905b0e77c9b98bc53f14b47e2a95/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f6867726163612f646f637472696e652d746573742d64622d726567656e65726174696f6e2d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://github.com/hgraca/doctrine-test-db-regeneration-bundle/releases)[![Total Downloads](https://camo.githubusercontent.com/42f84a6c64c7f42a46f8b85b35c26533c629b36c0fba8df0f5286a095285dc4b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6867726163612f646f637472696e652d746573742d64622d726567656e65726174696f6e2d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/hgraca/doctrine-test-db-regeneration-bundle)

[![Build Status](https://camo.githubusercontent.com/7e22a5b9d71b2c24e8dd499666ac4e1e1174bd53025d6debb2622956bd2b78d5/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6867726163612f646f637472696e652d746573742d64622d726567656e65726174696f6e2d62756e646c652f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/hgraca/doctrine-test-db-regeneration-bundle/build-status/master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/d988c17e6624a4a994a58ee9f6105aa65d60900257678d2f9b8c446545936401/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6867726163612f646f637472696e652d746573742d64622d726567656e65726174696f6e2d62756e646c652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/hgraca/doctrine-test-db-regeneration-bundle/?branch=master)[![Code Intelligence Status](https://camo.githubusercontent.com/c47e276fd12c8b150c9d585a69bcdd7edb6fdbe75af41ae17a5aa0f64989ce1c/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6867726163612f646f637472696e652d746573742d64622d726567656e65726174696f6e2d62756e646c652f6261646765732f636f64652d696e74656c6c6967656e63652e7376673f623d6d6173746572)](https://scrutinizer-ci.com/code-intelligence)[![CodeCov](https://camo.githubusercontent.com/98cef5ee2c5eecb3464ffc1bfe7fe988baa54fff8a1f6a85c108883ff6a1645a/68747470733a2f2f636f6465636f762e696f2f67682f6867726163612f646f637472696e652d746573742d64622d726567656e65726174696f6e2d62756e646c652f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/hgraca/doctrine-test-db-regeneration-bundle)

This is a Symfony 2/3/4 bundle, inspired on some code [@lcobucci](https://github.com/lcobucci) wrote back in 2017, to generate the test DB (if needed) for every test suite run or test method run.

When we have Integration tests that need to use a DB, the best practice is to have the tests use a SQLite DB for those tests. However, keeping the SQLite DB file in our repo is not a good practice, and using the same file for all tests neither, because tests should run in isolation from each other.

This bundle provides the functionality to generate the test DB SQLite file, and regenerate it for every test that needs a DB.

By default, at the beginning of a test run it will create a test database, based on the Doctrine fixtures, and a serialized fixtures object.

After generating those initial files, it will copy the backup DB SQLite file into the path of the DB SQLite file being used by the tests, but only before the tests implementing the tag interface `DatabaseAwareTestInterface` so that we don't regenerate the DB for tests that don't need it.

This last functionality, however, can be disabled so that we can use this bundle with another bundle like the [DAMA\\DoctrineTestBundle](https://github.com/dmaicher/doctrine-test-bundle), which provides similar functionality which will probably give you better performance. In such case, this bundle is only useful for generating the initial test DB.

Installation &amp; Setup
------------------------

[](#installation--setup)

1. install via composer

    ```
    composer require --dev hgraca/doctrine-test-db-regeneration-bundle
    ```
2. Enable the bundle for your test environment in your `AppKernel.php`, ie:

    ```
    if (in_array($env, ['dev', 'test'])) {
        ...
        if ($env === 'test') {
            $bundles[] = new Hgraca\DoctrineTestDbRegenerationBundle\HgracaDoctrineTestDbRegenerationBundle();
        }
    }
    ```
3. The bundle exposes a configuration that looks like this by default:

    ```
    hgraca_doctrine_test_db_regeneration:
        doctrine_service_id: 'doctrine'
        fixtures_loader_service_id: 'doctrine.fixtures.loader'
        test_db_bkp_path: '%kernel.cache_dir%/test.bkp.db'
        # The list of extra services to add to the container,
        # in case you want to reuse this already built container.
        extra_service_list: []
    ```
4. Add the PHPUnit test listener in your xml config (e.g. `app/phpunit.xml`)

    ```

        ...

    ```

    There are a few options you can use to tweak how it works. Below you can see the options with their default values:

    ```

        ...

                1
                1
                0

    ```

    I strongly advise using [DAMA\\DoctrineTestBundle](https://github.com/dmaicher/doctrine-test-bundle) as well, as in a platform with 1596 integration tests, it reduced the test execution time from 2m to 46s.

    If you are using [DAMA\\DoctrineTestBundle](https://github.com/dmaicher/doctrine-test-bundle) you will want to set it up like this:

    ```

        ...

                0
                0

    ```
5. Make your tests, that need DB access, implement the tag interface `DatabaseAwareTestInterface`, so it only recovers the DB for those tests.
6. Done! From now on the test database will be generated (if needed) at the beginning of running the tests, and at the beginning of every test tagged as `DatabaseAwareTestInterface`, if you did not disable this feature.

Available commands
------------------

[](#available-commands)

Run the test suites:

```
make test
```

Create th test coverage report:

```
make coverage
```

Fix the code standards:

```
make cs-fix
```

Manage the project dependencies:

```
make dep-install
make dep-update
```

Build the docker container used for testing:

```
make build-container-tst
```

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~60 days

Recently: every ~73 days

Total

6

Last Release

2685d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4af14428505ab93e698bb1fa7a540b0f71dbae0246b6c534f39011aaafc13717?d=identicon)[hgraca](/maintainers/hgraca)

---

Top Contributors

[![hgraca](https://avatars.githubusercontent.com/u/1809002?v=4)](https://github.com/hgraca "hgraca (14 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/hgraca-doctrine-test-db-regeneration-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/hgraca-doctrine-test-db-regeneration-bundle/health.svg)](https://phpackages.com/packages/hgraca-doctrine-test-db-regeneration-bundle)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[kimai/kimai

Kimai - Time Tracking

4.6k7.4k1](/packages/kimai-kimai)[contao/core-bundle

Contao Open Source CMS

1231.6M2.4k](/packages/contao-core-bundle)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

7310.3k29](/packages/open-dxp-opendxp)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
