wyrihaximus/test-utilities
A set of PHP test utilities for package development: a PHPUnit TestCase with helpers like random namespaces and temp directories, plus ready-made configuration defaults for PHPStan and Rector (paths and docblock-to-attribute conversions).
HttpTests, TestCase inheritance) and can enhance mocking, file storage tests, and API assertions.composer require installation with no runtime dependencies beyond PHPUnit/PHPStan/Rector.WyriHaximus\TestUtilities\TestCase is optional, allowing gradual adoption (e.g., start with Rector/PHPStan configs first).11.x pins Rector to 2.2.1), which could conflict with Laravel’s dependencies (e.g., if Laravel uses Rector 2.3+). Mitigation: Use ^12.x to avoid pinned versions.10.x) may lag behind. Risk: Tests may fail if not updated. Mitigation: Align Laravel’s PHPUnit to ^12.5 or use a separate test suite.Storage::fake() or temporary directories.TestCase?dev-dependencies) or project-wide?TestCase with WyriHaximus\TestUtilities\TestCase for randomized namespaces/directories (useful for file-based tests).ergebnis/phpunit-slow-test-detector) to optimize CI.RectorConfig for docblock-to-attribute migration (if using PHP 8.0+ attributes).HttpTestCase for API testing (e.g., mocking responses with randomized data).Storage facade alongside the package’s file utilities to avoid conflicts.composer.json with require-dev:
"wyrihaximus/test-utilities": "^12.2"
phpstan.neon/rector.php (minimal risk).WyriHaximus\TestUtilities\TestCase (prioritize file/storage tests).phpunit.xml to include slow-test detection.TestCase with a custom base class combining both utilities.12.x may require Laravel’s phpunit package to be updated (^12.5).2.3+ vs. Laravel’s dependencies (e.g., Symfony 7.x vs. 8.x).
^12.x of the package to avoid pinned versions.| Step | Priority | Effort | Dependencies |
|---|---|---|---|
Add to composer.json |
High | Low | None |
| Configure PHPStan/Rector | Medium | Medium | PHPStan/Rector installed |
Update PHPUnit to 12.x |
High | Medium | Laravel phpunit package |
| Migrate TestCases | Low | High | PHPUnit 12.x, CI adjustments |
| CI/CD Pipeline Updates | High | Medium | GitHub Actions/CircleCI config |
renovate-bot or dependabot for PHPUnit/PHPStan/Rector updates.TestCase require test suite-wide updates.Storage::fake().--cache flag).--parallel).| Risk | Impact | Mitigation |
|---|---|---|
| PHPUnit 12.x incompatibility | Tests fail in CI | Pin Laravel’s phpunit package |
| Rector conflicts | Build breaks | Use ^12.x to avoid pinned versions |
| Temp file leaks | Disk space exhaustion | Use Laravel’s Storage::fake() |
| Flaky randomized tests | Intermittent test failures | Seed randomization or disable in CI |
| PHPStan false positives | Dev frustration | Customize PHPStan config |
How can I help you explore Laravel packages today?