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).
TestCase inheritance) can leverage these utilities without architectural disruption.RefreshDatabase, MigrateFresh). Example: Randomized directories for file storage tests can mirror Laravel’s storage_path() logic.composer require wyrihaximus/test-utilities) and minimal configuration (e.g., extending TestCase) make adoption straightforward.DatabaseMigrations trait.Artisan testing helpers (e.g., Artisan::call()). May require wrapper classes.laravel-shift/phpstan-rules).HttpTests, FeatureTests) may require wrapping package utilities in Laravel-specific traits/classes.laravel-shift/phpstan-rules)?storage_path() or public_path()?TestCase (or create a custom trait) to inherit WyriHaximus\TestUtilities\TestCase.use WyriHaximus\TestUtilities\TestCase as BaseTestCase;
class MyTestCase extends BaseTestCase {
use CreatesApplication; // Laravel’s trait
}
phpstan.neon).rector.php with WyriHaximus\TestUtilities\RectorConfig or extend it.@mixin, @method).TestCase for new test files.--dry-run) to assess impact before full adoption.DatabaseMigrations.
trait DatabaseTestUtilities {
use \WyriHaximus\TestUtilities\TestCase;
use \Laravel\Sanctum\Http\EntrustsUser;
// Laravel-specific methods
}
Artisan helpers.composer.json overrides:
"extra": {
"laravel": {
"dont-discover": []
}
},
"config": {
"platform-check": false,
"allow-plugins": {
"wyrihaximus/test-utilities": {
"replace": {
"phpunit/phpunit": "9.5.22"
}
}
}
}
TestCase inheritance for new test files.README or wiki.phpstan-rules-wrapper).--memory-limit and caching (result-cache).CONTRIBUTING.md.| Risk | Impact | Mitigation |
|---|---|---|
| Dependency Conflicts | Broken tests/CI failures | Use composer.json overrides for version alignment. |
| Rector Breaking Changes | Docblock-to-attribute failures | Test in staging; use --dry-run for Rector. |
| PHPStan False Positives | Test suite flakiness | Merge extensions incrementally; validate against Laravel’s rules. |
| Laravel Version Drift | Package incompatibility | Pin package versions in composer.json. |
| CI Pipeline Bottlenecks | Slow test execution | Parallelize Rector/PHPStan runs. |
How can I help you explore Laravel packages today?