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

Mockery Pdo Laravel Package

mpyw/mockery-pdo

Experimental BDD-style PDO mocking library built on mockery/mockery. Define expectations for prepare/bind/execute and return rows via fetch/fetchAll in a fluent API, making PDO-based code easy to test on PHP 8.2+.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Database Testing Strategy: Enables robust unit/integration testing for database-dependent PHP applications, reducing reliance on external test databases or complex fixtures. Now PHP 8.2+ only, aligning with modern Laravel ecosystems (Laravel 10+).
  • BDD/ATDD Alignment: Supports behavior-driven development by allowing precise mocking of PDO interactions (e.g., queries, transactions) in a readable, test-first workflow. Updated PHP version support ensures compatibility with newer Laravel features like attributes-based testing.
  • Build vs. Buy: Justifies in-house test infrastructure investment for teams using Mockery and PDO, avoiding proprietary tools like Prophecy or custom solutions. The PHP 8.2 requirement may reduce maintenance overhead for teams already upgrading.
  • Performance-Critical Paths: Validates database logic without hitting real databases, accelerating CI/CD pipelines for high-frequency deployments. Faster PHP versions (8.2+) improve mocking performance in CI environments.
  • Legacy System Modernization: Facilitates testing of monolithic PHP apps with deep PDO dependencies, easing migration to modern architectures. The PHP 8.2 drop forces alignment with newer Laravel versions, simplifying long-term maintenance.
  • Security Testing: Mocks sensitive database operations (e.g., password hashing, token generation) to verify logic without exposing test data. Updated PHP support ensures compatibility with modern security libraries (e.g., PHP 8.2’s password hashing improvements).

When to Consider This Package

  • Avoid if:
    • Your team uses PHPUnit’s native DBUnit or Doctrine DBAL for testing—overlap may reduce value.
    • You’re already committed to Prophecy or Mockery’s built-in PDO mocks (though this package extends Mockery’s capabilities).
    • Testing requires real database state (e.g., complex joins, stored procedures)—consider Testcontainers or Dockerized DBs instead.
    • Your stack avoids PDO (e.g., uses Eloquent or Query Builder abstractions)—mocking at a higher level may suffice.
    • You’re still on PHP 7.x or 8.0/8.1—this package now requires PHP 8.2, making it incompatible with older Laravel versions (pre-10).
  • Consider if:
    • You need fine-grained control over PDO mocks (e.g., simulating slow queries, specific error codes).
    • Your tests involve transaction rollbacks, prepared statements, or connection pooling edge cases.
    • You’re adopting BDD (e.g., with Behat) and need to mock database interactions in step definitions.
    • Your CI environment has resource constraints (mocking avoids spinning up DB instances).
    • You’re upgrading to Laravel 10+ or PHP 8.2+—this package now aligns with modern stacks, reducing future migration friction.

How to Pitch It (Stakeholders)

For Executives: "This package lets our dev team test database interactions without real databases, cutting CI feedback loops from minutes to seconds. With PHP 8.2 support, it now integrates seamlessly with Laravel 10+, enabling faster releases while maintaining security. For example, we can simulate a failed payment query in milliseconds instead of waiting for a test DB—saving ~30% of QA time. It’s a low-risk, high-reward way to modernize our testing infrastructure, especially if we’re already upgrading to PHP 8.2."

For Engineers: *"If you’re using Mockery and PDO, this library now adds BDD-style mocking for queries, errors, and transactions—but only on PHP 8.2+. Key updates:

  • Dropped PHP 7.x support—aligns with Laravel 10+.
  • Faster mocking due to PHP 8.2 optimizations. Key use cases:
  • Mock a slow DB call: $mock->shouldReceive('prepare')->andReturnSelf()->once();
  • Test error handling without a real DB (e.g., simulate PDOException for deadlocks).
  • Integrate with Behat for feature tests. Start with a spike to validate if it reduces test flakiness—ideal for teams already on PHP 8.2."

For QA/DevOps: "This reduces test environment costs by eliminating dedicated test databases. With PHP 8.2 support, our smoke tests (currently 5 minutes with a real DB) could drop to under a minute by mocking critical paths. Critical for regression testing after DB schema changes—especially if we’re upgrading to Laravel 10+."

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.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor