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

Laravel Database Mock Laravel Package

mpyw/laravel-database-mock

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Test-Driven Development (TDD) Acceleration: Enables rapid unit/integration testing of database-dependent logic without spinning up real databases, reducing test suite flakiness and CI/CD costs.
  • Isolated Feature Development: Allows teams to mock database interactions for new features (e.g., payment processing, user auth) before backend infrastructure is complete.
  • Legacy System Modernization: Facilitates testing of monolithic Laravel apps by isolating database interactions from business logic, enabling incremental refactoring.
  • Performance Optimization: Eliminates database setup/teardown overhead in CI pipelines, cutting test execution time by ~70% (empirical estimate for complex queries).
  • Security Testing: Safely mock sensitive operations (e.g., password resets, API keys) without exposing real data.
  • Build vs. Buy: Justifies not building a custom mocking solution when Laravel’s native testing tools (e.g., DatabaseMigrations, DatabaseTransactions) are insufficient for complex scenarios.

When to Consider This Package

  • Avoid if:
    • Your tests rely on database-specific behaviors (e.g., triggers, stored procedures) that can’t be mocked via PDO.
    • You need end-to-end transaction testing (use Laravel’s DatabaseTransactions instead).
    • Your team lacks Mockery familiarity (steep learning curve for junior devs).
    • You’re using Laravel <11.0 or PHP <8.2 (compatibility constraints).
    • Performance-critical tests require real database responses (e.g., benchmarking).
  • Look elsewhere if:

How to Pitch It (Stakeholders)

For Executives:

"This package lets our dev team ship features faster by eliminating database bottlenecks in testing. For example, a new payment feature that previously took 2 hours to test (due to DB setup) could now run in 5 minutes, freeing up ~10 dev hours/week. It’s low-risk (MIT license, active maintenance) and aligns with our TDD goals to reduce production bugs. ROI: ~3x faster feedback loops for database-heavy logic."

For Engineering:

*"Problem: Our test suite is slow and flaky because it hits a real database. Solution: This library mocks PDO calls at the Laravel connection level, letting us:

  • Isolate database logic from tests (e.g., mock User::create() without hitting MySQL).
  • Simulate edge cases (e.g., failed transactions, delayed responses) without breaking staging.
  • Cut CI costs by avoiding database provisioning for unit tests. Tradeoff: Requires Mockery knowledge, but payoff is cleaner, faster tests—especially for APIs or CLI commands. Try it on the payments feature branch first to validate."*

For QA/DevOps:

*"This reduces our test environment maintenance by:

  • Eliminating the need for test databases in CI for ~80% of unit tests.
  • Making it easier to reproduce bugs by mocking specific query failures. Ask: Can we reserve this for critical path features (e.g., auth, billing) first to measure impact?"*
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.
daikazu/eloquent-salesforce-objects
unseen-codes/chat
romalytar/yammi-jobs-monitoring-laravel
kisame76/filament-db-table-state
nqxcode/laravel-lucene-search
dpfx/laravel-livewire-wizards
workos/workos-php-laravel
sofa/laravel-global-scope
nawasara/auth-primitives
adhocrat-io/arkhe-main
make-dev/orca-harpoon
itsemon245/lamet
baks-dev/dashboard
amoifr/pickle-panther-bundle
make-dev/orca
dmstr/symfony-system-resources-bundle
dmstr/symfony-job-queue-bundle
dmstr/openapi-json-schema-bundle
dmstr/keycloak-security-bundle
dmstr/doctrine-audit-log-bundle