automattic/phpunit-select-config
Small utility for PHPUnit projects that helps select or switch the PHPUnit configuration file to use when running tests. Handy for repos with multiple phpunit.xml variants (e.g., local vs CI) and scripts that need consistent config selection.
@group or versioned configs).php artisan test and TestCase bootstrapping can leverage this package to abstract config selection, reducing manual intervention in CI/CD scripts. However, it does not replace Laravel’s built-in test helpers (e.g., refreshDatabase()) but can complement them by managing config files.--configuration, this package adds minimal value. The 44.59 "opportunity" score suggests high potential for projects with complex test environments.phpunit calls with phpunit-select-config, enabling gradual adoption.php artisan test:versioned) for Laravel-native workflows.TestCase bootstrapping (e.g., service providers, app bindings). Requires testing.phpunit.9.xml, phpunit.10.xml) adds discipline but reduces flexibility.| Risk | Severity | Mitigation |
|---|---|---|
| Unmaintained Package | High | Fork and maintain; or replace with a custom script (e.g., Bash/PHP wrapper). |
| Laravel TestCase Conflicts | Medium | Test with TestCase overrides; document limitations. |
| CI Pipeline Breaks | Medium | Implement fallback to default phpunit.xml in CI. |
| Performance Overhead | Low | Benchmark in CI; negligible for most use cases. |
| Version Lock-In | Low | Pin PHPUnit version in composer.json to avoid breakage. |
phpunit.xml with includes sufficient?
TestCase and service providers?
TestCase to ensure no bootstrapping conflicts.phpunit.xml or a custom error handler.pest or lighthouse?
TEST_CONFIG=phpunit.xml.ci) for flexibility.phpunit.xml differently).composer require --dev automattic/phpunit-select-config
./vendor/bin/phpunit-select-config phpunit.*.xml.dist
phpunit.9.xml, phpunit.10.xml) and validate selection.app/Console/Commands/TestVersioned.php):
use Automattic\PHPUnitSelectConfig\Runner;
class TestVersioned extends Command {
protected $signature = 'test:versioned {config=phpunit.xml}';
public function handle() {
$runner = new Runner($this->argument('config'));
$runner->run();
}
}
php artisan test with php artisan test:versioned in local workflows.# .github/workflows/test.yml
- run: php artisan test:versioned phpunit.xml.ci
TEST_CONFIG=phpunit.xml.feature-x php artisan test:versioned
TestWorker to use the package’s runner:
// app/Providers/AppServiceProvider.php
public function boot() {
if ($this->app->runningUnitTests()) {
$config = config('testing.config');
$runner = new Runner($config);
$runner->runTests();
}
}
| Component | Compatibility Notes |
|---|---|
| Laravel | Works with Laravel 8+ (PHPUnit 9+). Test with Laravel 10+ for regressions. |
| PHPUnit | Requires PHPUnit 8.0+. May need polyfills for older versions (e.g., PHPUnit 7). |
| CI Tools | Compatible with any CLI-based CI (GitHub Actions, Jenkins, etc.). |
| Pest | Limited support; may require custom pest.php config overrides. |
| Lighthouse | Possible with custom test runners, but untested. |
phpunit --configuration calls).phpunit.xml.ci) in CI.phpunit.xml.feature, phpunit.xml.legacy)..env or CI variables to control configs dynamically.phpunit.{version}.xml).composer.json to avoid breakage.phpunit --dry-run).README.md with config naming conventions.CONTRIBUTING.md section for test config management.phpunit.xml) if the package fails.--debug flag to the Artisan command.phpunit.{version}.xml exists.phpunit --version).--debug to see selected config:
php artisan test:versioned --debug
TEST_CONFIG environment variables are set.How can I help you explore Laravel packages today?