sanmai/phpunit-double-colon-syntax
Run individual PHPUnit test methods with the familiar file::method syntax (like pytest). This dev package rewrites args via Composer autoload so vendor/bin/phpunit tests/FooTest.php::testBar becomes file + --filter automatically. Supports multiple methods; PHPUnit 6+.
phpunit.xml) or Laravel service provider modifications are needed, reducing technical debt and maintenance overhead. This is critical for Laravel’s modular ecosystem, where packages should not impose invasive setup requirements.file::method to PHPUnit’s native --filter syntax (e.g., tests/UserTest.php::testLogin → tests/UserTest.php --filter testLogin), ensuring backward compatibility with existing test runners, CI/CD pipelines, and Laravel’s phpunit alias.php artisan test UserTest::testLogin → not supported; this package targets vendor/bin/phpunit only).refreshDatabase(), withoutMiddleware()) remain unaffected..github/workflows/test.yml).Test::testLogin, this package provides a low-risk migration path for legacy projects or teams using PHPUnit.vendor/bin/phpunit, not Laravel’s php artisan test command. This requires developers to explicitly use vendor/bin/phpunit (or alias it in ~/.bashrc/~/.zshrc).--filter Hybrid: Conflicts arise if mixing file::method with --filter (e.g., phpunit UserTest.php::testLogin --filter testLogin). Developers must choose one syntax per command.testLogin in UserTest.php and AdminTest.php), the package does not resolve conflicts—PHPUnit’s native behavior applies.file::method as invalid (though the package’s runtime transformation mitigates this for execution).--filter in future PHPUnit versions.file::method over PHPUnit’s native --filter or PestPHP’s syntax? Conduct a small pilot with a subset of tests to measure productivity gains.php artisan test? Should the team alias php artisan test to vendor/bin/phpunit for consistency?--filter syntax? Audit pipelines for breaking changes.--parallel flag.file::method syntax (e.g., UserTest.php::nonexistentMethod) be communicated to developers? The package falls back to PHPUnit’s native errors, which may be less intuitive.TestCase inheritance or createApplication() methods.phpunit --filter with phpunit tests/UserTest.php::testLogin in workflows.phpunit aliases, ~/.bashrc).README.md test examples).UserTest.php, FeatureTest.php) to pilot the new syntax.composer require --dev sanmai/phpunit-double-colon-syntax
phpunit UserTest.php::testLogin).--filter commands in documentation (after 3–6 months).# Old (deprecated)
vendor/bin/phpunit --filter testLogin
# New (recommended)
vendor/bin/phpunit UserTest.php::testLogin
--filter is used without file::method.| Component | Compatibility | Mitigation |
|---|---|---|
| PHPUnit 6–13 | ✅ Full support | None required. |
| Laravel 8–11 | ✅ Works with default PHPUnit setup | Test with Laravel’s phpunit.xml configuration. |
| PestPHP | ⚠️ Not applicable (Pest has native syntax) | Recommend PestPHP for new projects. |
| PHP 7.1–8.5 | ✅ Supported (Laravel’s PHP 8.0+ removes concern) | None required. |
| Parallel Testing | ✅ No impact | Verify with --parallel flag. |
| Static Analysis | ⚠️ May flag file::method as invalid |
Add // @phpstan-ignore-line or configure tools to ignore CLI-specific syntax. |
| Artisan Test Command | ❌ Not supported (targets vendor/bin/phpunit only) |
Alias php artisan test to vendor/bin/phpunit or update team workflows. |
phpunit.xml and CI/CD workflows.phpunit --filter testLogin).composer require --dev sanmai/phpunit-double-colon-syntax in the project root.vendor/bin/phpunit tests/UserTest.php::testLogin
--filter syntax.--filter withHow can I help you explore Laravel packages today?