Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Doctrine Test Bundle Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Accelerating CI/CD Pipelines: Adopting this package directly addresses the bottleneck of slow database-driven tests, reducing test suite execution time by eliminating schema rebuilds and fixture reloads per test. This enables faster feedback loops for developers, particularly for teams with high test volume (e.g., >1000 tests) or complex Doctrine entities.
  • Shift from "Build" to "Buy" for Test Isolation: For teams already using Symfony/Doctrine, this package replaces custom test isolation logic (e.g., manual transactions, backup/restore scripts) with a maintained, battle-tested solution. Reduces technical debt in test infrastructure.
  • Enabling Scalable Test Suites: Supports parallel test execution (via static connections) without race conditions, critical for large-scale monorepos or microservices with shared test databases.
  • Roadmap for Test Reliability: Aligns with initiatives to:
    • Improve flakiness: Isolated transactions prevent test pollution.
    • Support attribute-based testing (e.g., #[SkipDatabaseRollback] for edge cases like debugging).
    • Future-proofing: Compatible with PHPUnit 13, Symfony 8+, and Doctrine 3.x.
  • Use Cases:
    • API/Controller Tests: Rollback database changes after each HTTP request test.
    • Integration Tests: Isolate multi-entity workflows without side effects.
    • Behat/Gherkin Scenarios: Automatically reset state between scenarios (where same-process execution is possible).

When to Consider This Package

  • Adopt if:

    • Your test suite spends >30% of runtime on database operations (e.g., schema rebuilds, fixture loading).
    • You use Symfony + Doctrine and want to avoid custom transaction management.
    • Tests fail intermittently due to shared state (e.g., INSERT/UPDATE conflicts).
    • Your team prioritizes CI speed (e.g., GitHub Actions, GitLab CI with timeouts).
    • You need debuggability (temporary commits for inspection without modifying tests).
  • Look Elsewhere if:

    • Your tests require DDL changes (e.g., ALTER TABLE) that can’t be rolled back (use temporary test databases instead).
    • You use multi-process testing (e.g., Selenium, Dockerized tests) where static connections won’t work.
    • Your stack doesn’t support PHP 8.2+ (e.g., legacy PHP 7.4).
    • You need cross-language test isolation (e.g., Python + PHP sharing a DB; consider test containers).
    • Your tests rely on implicit commits (e.g., MySQL’s AUTOCOMMIT=1; configure use_savepoints: true or refactor).

How to Pitch It (Stakeholders)

For Executives/Stakeholders:

"This package cuts test suite runtime by 50–80% by eliminating redundant database operations. For a team running 2,000 tests daily, that’s ~10–15 hours saved per week in CI costs—equivalent to 2 full-time engineers. It’s a zero-risk upgrade (MIT-licensed, used by Symfony’s demo app) that improves reliability while reducing infrastructure costs. No code changes needed; just install and enable."

Key Outcomes: ✅ Faster releases: Shorter CI feedback loops. ✅ More reliable tests: No flakiness from shared state. ✅ Lower cloud costs: Fewer failed retries due to timeouts. ✅ Future-proof: Works with modern PHP/Symfony stacks.


For Engineering Teams:

*"The DAMA Doctrine Test Bundle replaces manual transaction management with a smart, configurable wrapper that:

  • Rolls back all DB changes per test (no schema rebuilds or fixtures).
  • Caches metadata/queries in-memory (faster Doctrine operations).
  • Supports selective rollback skipping for debugging (e.g., #[SkipDatabaseRollback]).
  • Works with PHPUnit/Behat and Symfony’s test utilities.

Implementation:

  1. Add to composer.json (dev dependency).
  2. Enable in bundles.php and phpunit.xml.
  3. Configure use_savepoints: true in Doctrine DBAL (if using DBAL <4).

Trade-offs:

  • Not for multi-process tests (e.g., Selenium).
  • Requires PHP 8.2+ (drop-in replacement for older versions exists).
  • Avoid DDL in tests (or use temporary commits for debugging).

Next Steps:

  • Benchmark current test suite runtime.
  • Validate compatibility with our Doctrine setup.
  • Pilot in a non-critical branch (e.g., feature flags)."*
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport
twbs/bootstrap4
php-http/client-implementation
phpcr/phpcr-implementation
cucumber/gherkin-monorepo
haydenpierce/class-finder
psr/simple-cache-implementation
uri-template/tests