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

Php Mock Mockery Laravel Package

php-mock/php-mock-mockery

Integrates php-mock with Mockery to mock PHP built-in functions in tests. Create namespaced function mocks with PHPMockery::mock() and set expectations/returns, then call Mockery::close(). Supports only unqualified calls; define early if needed.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Enables testing of legacy code with hard dependencies on PHP built-in functions (e.g., time(), rand(), filesystem operations) without requiring dependency injection refactoring, preserving existing architecture.
  • Accelerates test coverage for non-deterministic logic (e.g., time-sensitive workflows) by providing deterministic test environments, reducing flaky tests in CI/CD pipelines.
  • Reduces build-vs-buy tradeoffs: leverages existing Mockery/PHPUnit tooling instead of developing custom mocking solutions, saving engineering effort.
  • Supports strategic roadmap goals focused on reliability and maintainability of legacy systems, avoiding high-risk "rewrite-first" approaches.

When to Consider This Package

  • ✅ Adopt when:
    • Testing legacy code with tight coupling to non-injectable PHP functions where refactoring is impractical or too costly.
    • Existing tests use PHPUnit and Mockery, and you need to mock built-in functions with familiar syntax.
    • Targeted function mocking (e.g., namespaced overrides) is required to avoid global side effects.
  • ❌ Avoid when:
    • Codebase already uses dependency injection patterns (e.g., constructor injection for time services).
    • Working with alternative testing frameworks (e.g., Pest) that have better native mocking capabilities.
    • Project requires high community support or enterprise-grade maintenance (low GitHub stars and recent activity may indicate limited adoption).

How to Pitch It (Stakeholders)

  • Executives: "This tool lets us test critical legacy systems faster and more reliably without diverting engineering resources to costly code rewrites. By ensuring deterministic tests for time-sensitive and external dependencies, we reduce production bugs and accelerate feature delivery while maintaining existing architecture."
  • Engineering: "It integrates seamlessly with your current PHPUnit/Mockery setup, allowing you to mock built-in functions like time() or rand() using familiar syntax—no refactoring needed. Just add a few lines to your tests for deterministic results, even for hard-to-isolate side effects like filesystem or network calls."
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
christhompsontldr/phpsdk
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