wyrihaximus/async-test-utilities
Async testing utilities for PHP/React: extend AsyncTestCase to run each PHPUnit test inside a Fiber with a default 30s timeout. Includes TimeOut attribute (class/method), plus helpers like random namespaces/directories and callable expectation utilities.
TestCase, requiring custom bootstrapping to integrate fibers.AsyncTestCase, which does not inherit from Laravel’s TestCase. A custom base test class would need to bridge both:
class AsyncLaravelTestCase extends \WyriHaximus\AsyncTestUtilities\AsyncTestCase
{
public function createApplication(): void { /* Laravel setup */ }
}
react/event-loop) and PHPUnit 12+, which may conflict with Laravel’s default symfony/http-client or guzzlehttp/guzzle. Resolution: Use alias dependencies or composer overrides to avoid version clashes.database:transactions) would require custom adapters or mocking.RefreshDatabase, Migrate), requiring manual overrides.react/event-loop coexist with Laravel’s async stack (e.g., Swoole, Amp)? Will dependency conflicts arise?--parallel) interact with fiber-based execution?react/promise).Phase 1: Pilot Integration
AsyncLaravelTestCase extending AsyncTestCase with Laravel bootstrapping.Phase 2: Dependency Alignment
phpunit/phpunit to ^12.5 (or use composer overrides).react/event-loop and Laravel’s async stack (e.g., Swoole)."scripts": {
"test:async": "phpunit --testdox-html --filter AsyncTestCase"
}
Phase 3: Full Adoption
sleep(1) hacks) with fiber-based alternatives.@TimeOut(5) for slow APIs).React\Debug\debug()).Fiber::suspend()). Older versions will fail.| Step | Task | Dependencies |
|---|---|---|
| 1 | Create AsyncLaravelTestCase |
wyrihaximus/async-test-utilities, react/event-loop |
| 2 | Update PHPUnit to ^12.5 | phpunit/phpunit |
| 3 | Pilot test suite migration | Existing async tests |
| 4 | Resolve dependency conflicts | Laravel’s composer.json |
| 5 | CI/CD pipeline updates | GitHub Actions/GitLab CI |
| 6 | Team training | Documentation, examples |
sleep(1) hacks).expectCallableOnce()).Fiber::getCurrent()).React\Debug\debug() will be essential.RefreshDatabase).sleep() delays).--parallel may not work with fibers (risk of event loop conflicts).| Risk | Mitigation |
|---|---|
| Fiber leaks | Use Fiber::suspend() in tearDown() or a custom trait for cleanup. |
| Timeout storms | Enforce strict timeout rules (e.g., @TimeOut(2) for fast tests). |
| Dependency conflicts | Use composer overrides or alias dependencies (e.g., react/promise). |
| PHPUnit 12+ breaking changes | Pin versions until Laravel officially supports it. |
| Database test failures | Mock async DB operations or use sync test suites for Eloquent. |
How can I help you explore Laravel packages today?