Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Phpunit Double Colon Syntax

Phpunit Double Colon Syntax Laravel Package

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+.

View on GitHub
Deep Wiki
Context7

Double Colon Syntax Support for PHPUnit. Makes Foo.php::testBar just work.

Frequently asked questions about Phpunit Double Colon Syntax
Does this package work with Laravel’s `php artisan test` command?
No, this package only intercepts `vendor/bin/phpunit` commands. Laravel’s `php artisan test` uses a different execution path and won’t support the `file::method` syntax. You’ll need to explicitly use `vendor/bin/phpunit` or alias it in your shell config.
Can I use `file::method` alongside PHPUnit’s `--filter` in the same command?
No, the package doesn’t support mixing both syntaxes. If you use `phpunit UserTest.php::testLogin --filter testLogin`, it will conflict. Stick to one syntax per command—either `file::method` or `--filter` alone.
Will this break Laravel’s parallel test execution (e.g., `--parallel`)?
No, the package doesn’t interfere with PHPUnit’s parallel testing capabilities. It only transforms the syntax before PHPUnit initializes, so existing parallel test setups will continue to work as expected.
Does this work with Laravel’s default PHPUnit setup (PHPUnit 10/11/12 + PHP 8.0+)?
Yes, the package is fully compatible with Laravel’s default PHPUnit configuration. It requires no changes to `phpunit.xml` or Laravel’s test helpers (like `refreshDatabase()` or `withoutMiddleware()`).
What happens if I run a test method that doesn’t exist (e.g., `UserTest.php::nonexistentMethod`)?
The package falls back to PHPUnit’s native error handling, which may not clearly indicate the syntax transformation. For better clarity, consider adding a custom error message or validating method names before running tests.
Can I use this with PestPHP in Laravel?
PestPHP already supports `Test::testMethod` syntax natively, so this package isn’t needed for Pest. However, it provides a low-risk way to adopt `file::method` syntax in legacy Laravel projects still using PHPUnit.
Will this work in CI/CD pipelines (GitHub Actions, CircleCI, etc.)?
Yes, the package integrates seamlessly with CI/CD workflows. Since it transforms syntax at runtime, no changes are needed in workflow files (e.g., `.github/workflows/test.yml`). Existing `--filter` commands won’t break, but you’ll need to update them to use `file::method` if desired.
Does this package support PHPUnit 13 or future versions?
The package is designed to support PHPUnit 13 and beyond, but Laravel’s adoption timeline for newer PHPUnit versions is uncertain. Monitor PHPUnit’s roadmap for potential deprecations of the `--filter` flag, which this package relies on.
How do I handle ambiguous method names (e.g., `testLogin` in multiple test classes)?
The package doesn’t resolve ambiguity—PHPUnit’s native behavior applies. If multiple test classes have similarly named methods, you’ll need to specify the full file path (e.g., `tests/UserTest.php::testLogin`) or use `--filter` explicitly.
Are there any alternatives to this package for Laravel?
For Laravel projects, PestPHP is the recommended alternative, offering a more expressive syntax (`Test::testMethod`). If you’re committed to PHPUnit, you can manually use `--filter` or alias `vendor/bin/phpunit` to your preferred syntax. This package is ideal for teams resistant to PestPHP but wanting `file::method` convenience.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor