dama/doctrine-test-bundle
A Symfony bundle that speeds up Doctrine tests by wrapping DBAL connections in a static driver and rolling back a transaction after each test, keeping tests isolated without schema rebuilds or fixture reloads. It also configures a PSR-6 static array cache.
Psr6StaticArrayCache for metadata and query caching is a significant performance booster, especially for test suites with heavy Doctrine usage (e.g., controller tests or integration tests).use_savepoints requirement for DBAL < 4 is the only notable constraint.behat.yml extension registration is unchanged), and the new unclosed-transaction warning is emitted by default without requiring opt-in.ALTER TABLE, DROP TABLE) or queries that implicitly commit transactions (e.g., MySQL's LOAD DATA) will fail. This requires discipline in test design or explicit opt-outs (#[SkipDatabaseRollback]).StaticDriver::commit()). This could frustrate developers unfamiliar with the bundle's behavior. Partially mitigated in v8.7.0 — the bundle now warns about transactions that were never closed, surfacing a previously silent failure mode.symfony/phpunit-bridge adds another layer of compatibility to manage.symfony/phpunit-bridge), this release could turn previously green builds red without any change in application code — a low-severity but non-zero rollout risk.Test Suite Maturity:
Debugging Workflow:
CI/CD Impact:
Multi-Environment Support:
Adoption Strategy:
Long-Term Maintenance:
| Component | Supported Versions | Notes |
|---|---|---|
| Symfony | 6.4+, 7.0+, 8.0+ | Flex-compatible |
| PHP | 8.1+ | CI validates up to PHP 8.6 (v8.7.0) |
| PHPUnit | 11, 12, 13 | PHPUnit 13 now allowed as dev dependency |
| Doctrine DBAL | 3+, <4 (with use_savepoints) |
DBAL 4+ may need configuration checks |
| Doctrine ORM | 2.10+ | Compatible with Symfony's DoctrineBundle |
| Behat | 3.x, 4.x | Behat 4 support added in v8.7.0 |
Pre-Integration Checks:
LOAD DATA, CREATE INDEX). Refactor or annotate these tests with #[SkipDatabaseRollback].use_savepoints: true is configured in config/packages/doctrine.yaml.Installation:
composer require --dev dama/doctrine-test-bundle
config/bundles.php (Symfony Flex handles this automatically if using Flex).phpunit.xml):
<extensions>
<bootstrap class="DAMA\DoctrineTestBundle\PHPUnit\PHPUnitExtension" />
</extensions>
Configuration:
behat.yml:
extensions:
DAMA\DoctrineTestBundle\Behat\ServiceContainer\DoctrineExtension: ~
Testing:
Post-Integration:
#[SkipDatabaseRollback]).Phase 1: Preparation (1–2 sprints):
Phase 2: Integration (1 sprint):
Phase 3: Validation (1 sprint):
Phase 4: Rollout (1 sprint):
StaticDriver::commit(). The v8.7.0 unclosed-transaction warning reduces the "silent leak" class of debugging pain but adds a new signal the team must own.php-cs-fixer/shim) with no consumer-facing effect — no action required.| Failure Mode | Symptom | Mitigation |
|---|---|---|
| DDL / implicit commit in a test | Test fails or leaks state unexpectedly | Refactor, or annotate with #[SkipDatabaseRollback] |
| Unclosed transaction (new warning, v8.7.0) | Warning emitted during test run; possible CI failure under warning-as-error | Triage per test; fix lifecycle bug or suppress deliberately |
| Debug session needs persisted state | Data appears to "vanish" after each test | Call StaticDriver::commit() or disable rollback temporarily |
| Memory growth in long suites | Runner OOM or slowdown late in the run | Disable caching features; split suite; raise memory limit |
| Dependency floor moved | Composer resolve failure after a minor bump | Pin version; schedule upgrade window; track PHPUnit/Symfony/PHP ceilings |
| Behat 4 upgrade mismatch | Extension fails to register | Confirm bundle ≥ 8.7.0 before upgrading Behat |
composer update and a warning triage pass.How can I help you explore Laravel packages today?