wyrihaximus/test-utilities
Shared test utilities for PHP projects: a PHPUnit TestCase with helpers like random namespaces and temp directories, plus ready-to-use PHPStan defaults and a preconfigured RectorConfig for common project layouts and doc-tag to attribute conversions.
TestCase, RectorConfig, PHPStan extensions) that aligns well with Laravel’s PHPUnit-based testing ecosystem. It abstracts away boilerplate (e.g., random namespaces/directories for file storage tests) and integrates with modern tooling (PHPUnit 12.x, PHPStan 2.x, Rector).TestCase) make adoption straightforward. The RectorConfig simplifies attribute migration for Laravel projects using docblocks.composer.json or use platform-specific overrides.laravel/framework updates or custom config).HttpTestCase or DatabaseTestCase.TestCase or create a Laravel-specific wrapper.phpunit.xml or phpstan.neon?TestCase be extended to include Laravel-specific helpers (e.g., refreshDatabase())?RectorConfig support Laravel’s directory structure (e.g., app/, database/)?tests/TestCase + custom traits suffice, or does this package’s abstraction justify the risk?tests/Feature).@throws → #throws) via Rector.platform-check in composer.json to enforce PHPUnit 12.x:
"config": {
"platform-check": false,
"platform": {
"phpunit/phpunit": "12.5.16"
}
}
DatabaseMigrations trait or RefreshDatabase.TestCase to include Laravel\Http\Testing\TestResponse.tests/Unit).TestCase for file storage operations and RectorConfig for attribute migration.WyriHaximus\TestUtilities\TestCase.phpunit.xml to use the package’s PHPStan extensions.composer.json to pin versions and add platform checks.| Component | Compatibility | Mitigation |
|---|---|---|
| PHPUnit | Laravel 10.x (v10.x) vs. Package (v12.x) | Pin versions or upgrade Laravel’s PHPUnit. |
| PHPStan | Laravel’s default (v1.x) vs. Package (v2.x) | Use phpstan.neon overrides or upgrade. |
| Rector | May conflict with Laravel’s rector.php config |
Merge configs or use package’s RectorConfig. |
| File System Tests | Random directories work but may clash with Laravel’s storage/ or public/ paths. |
Configure allowed paths in TestCase. |
| Database Testing | No built-in support | Combine with Laravel’s RefreshDatabase. |
phpunit.xml, phpstan.neon).TestCase in a single test file.phpunit.xml to include PHPStan extensions.composer update.TestCase extensions (e.g., Laravel HTTP testing).TestCase class if the package becomes unsustainable.| Risk | Impact | Mitigation |
|---|---|---|
| Dependency Conflicts | Breaks tests if PHPUnit/PHPStan versions clash. | Pin versions in composer.json. |
| Rector Migration Issues | Attribute conversion fails or introduces bugs. | Test Rector in a staging environment first. |
| Laravel Toolchain Divergence | Package lags behind Laravel’s PHPUnit/PHPStan updates. | Monitor Laravel’s road |
How can I help you explore Laravel packages today?