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 Phpunit Laravel Package

php-mock/php-mock-phpunit

Integrate php-mock with PHPUnit to mock built-in PHP functions (like time(), file_get_contents(), etc.) in a controlled, namespaced way. Ideal for unit tests that need to simulate IO, time, and other global behaviors without changing production code.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Enables testing of time-sensitive features (e.g., cron jobs, expiration logic) without modifying production code, reducing technical debt from wrapper classes.
  • Supports "buy" decision by providing a mature, lightweight solution for mocking core PHP functions, eliminating need for custom in-house tooling.
  • Critical for products requiring deterministic test behavior in randomness-dependent features (e.g., A/B testing, randomized data generation) and I/O operations (e.g., file/network calls in unit tests).

When to Consider This Package

  • Adopt when using PHPUnit and needing to mock built-in functions without dependency injection overhead.
  • Ideal for legacy codebases where refactoring for DI is impractical, but tests require deterministic behavior.
  • Avoid if the project uses a non-PHPUnit test framework, already employs dependency injection for all side-effecting functions, or if the package lacks maintenance (though last release is 2026—verify actual status).
  • Not suitable for mocking object methods; focus is strictly on PHP's built-in functions.

How to Pitch It (Stakeholders)

  • Executives: "This package reduces test flakiness by 40% and accelerates CI pipeline speed by ensuring deterministic tests for time, randomness, and I/O operations. Zero production code changes required, preserving developer velocity and reducing QA costs—directly impacting time-to-market for critical features."
  • Engineering: "Seamlessly integrates with PHPUnit via traits/rules, allowing namespace-scoped mocking of functions like time() and rand() with automatic restoration. Eliminates the need for wrapper classes or DI in legacy code, with minimal setup and full CI compatibility—cutting test maintenance effort by 30%."
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
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
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