dama/doctrine-test-bundle
Symfony test bundle that speeds up Doctrine tests by reusing static DBAL connections and wrapping each test in a transaction that’s rolled back for isolation. Also provides a PSR-6 static array cache for Doctrine metadata/query caching to reduce boot time and memory.
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.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.symfony/phpunit-bridge adds another layer of compatibility to manage.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+ | PHP 8.0 and below unsupported |
| PHPUnit | 11, 12, 13 | Requires PHPUnit 10+ |
| Doctrine DBAL | 3+, <4 (with use_savepoints) |
DBAL 4+ may need configuration checks |
| Doctrine ORM | 2.10+ | Compatible with Symfony’s DoctrineBundle |
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().How can I help you explore Laravel packages today?