fp/fumocker
Fumocker is a lightweight PHP library for mocking function calls in unit tests. It helps you stub built-in or namespaced functions, isolate code from side effects, and write more predictable tests without introducing heavy testing dependencies.
Clock/Randomizer abstraction today.runkit7/uopz) or over DI/clock patterns — that's a standards call with long-tail consequences.Consider it when:
time(), rand(), file_get_contents(), or curl_exec() are called directly and cannot be wrapped or injected without a rewrite that isn't funded.Look elsewhere when:
php-mock/php-mock-phpunit, Mockery, or Symfony's Clock are better maintained and better documented.For executives: This is a zero-cost, MIT-licensed testing utility that helps engineers get automated test coverage onto older PHP code without a rewrite. It carries no licensing cost and no production runtime risk, because it is dev-only. The catch is maturity: near-zero community adoption, no vendor support, and a pre-PHP-7 footprint mean the ongoing maintenance is ours, not the community's. Treat it as a tactical, time-boxed pilot with a decision gate — not a platform commitment. Recommendation: fund a short spike in one legacy test area, run it head-to-head against a better-supported alternative, and require a documented exit plan before any broader rollout. Do not let a 7-star test helper hold back a platform upgrade.
For engineering leads: Fumocker lets tests override unqualified PHP function calls without PECL extensions, which is genuinely useful for legacy paths that hit globals directly. The trade-offs are maturity and mechanics: mocks are process-global and can leak between tests, only unqualified calls are interceptable, and code must be loaded through the scope after registration — meaning opcache off in CLI and careful setUp/tearDown discipline. Constrain it: dev-only dependency, exact version pin, isolated test groups, a base test case that always unregisters, and a @todo extract marker on every mock so the count is tracked as debt. Pilot on one suite, measure setup friction and stability gain, and standardize only if it clearly beats php-mock/php-mock-phpunit or a straight refactor. If it can't be installed on your current PHP line, stop — don't bend the platform for a test utility.
How can I help you explore Laravel packages today?