icecave/isolator
Icecave Isolator isolates and mocks PHP global state for testing. It provides PHPUnit integration to snapshot and restore global variables, superglobals, constants, and functions, so each test runs in a clean, predictable environment free of hidden state leakage and side effects.
time(), mt_rand(), file_get_contents(), curl_exec(), sleep()) inside a test, so brittle procedural code can be covered with characterization tests before anyone commits to the cost of refactoring it to injectable services. This is a "buy a bridge, defer the rebuild" decision.expires_at?") without sleeping in tests or shipping a clock abstraction first.Consider it when:
Look elsewhere when:
getMock) that were removed/changed in PHPUnit 6+; assume it needs patching or a fork. The 35-star, effectively single-maintainer footprint is a real bus-factor signal.Psr\Clock\ClockInterface), a PSR-18 HTTP client, and a filesystem abstraction (Flysystem) instead. Those are stable, well-maintained, and make the dependency explicit rather than magical.php-mock/php-mock (actively maintained, same problem space) is the lower-risk call. Symfony's PHPUnit Bridge ClockMock covers the time-only case.To executives: This is a zero-runtime-risk, MIT-licensed testing utility we would add as a dev-only dependency. It buys us the ability to put automated tests around legacy modules — particularly anything involving time, randomness, or network calls — without funding a refactor first. That directly reduces the cost of change and the frequency of flaky CI failures, and it lets us ship riskier features (retries, expiry, rate limits) with real evidence they behave at the edges. The caveat to state plainly: the package has not been released since 2015 and has a single-maintainer footprint, so I am recommending it as a transitional tool with a defined exit path — not as a permanent architectural commitment. Budget a small spike (1–2 days) to confirm it runs on our PHP/PHPUnit versions before we plan around it.
To engineering: Treat this as scaffolding, not architecture. It isolates global function calls so they can be stubbed in tests — the right move for legacy code you're not ready to refactor. But it's unmaintained since 2015 and depends on PHPUnit APIs that modern versions removed; expect to fork or pin. So: use it in modules we plan to touch anyway, write the tests, then replace it with injected collaborators (clock, HTTP client, filesystem) as we refactor out. If we're starting greenfield or already on PHP 8, skip it and inject the dependency — php-mock/php-mock is the maintained alternative if we need function-level mocking at all.
How can I help you explore Laravel packages today?