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 using the familiar file::method syntax: vendor/bin/phpunit tests/FooTest.php::testBar. Supports multiple methods, no config, works with PHPUnit 6+. Translates to --filter under the hood (not compatible with --filter).

View on GitHub
Deep Wiki
Context7

Double Colon Syntax for PHPUnit

Frequently asked questions about Phpunit Double Colon Syntax
Does this package work with Laravel’s default PHPUnit setup (v6–13) and PHP 8.0+?
Yes, it’s fully compatible with Laravel’s default PHPUnit configuration. No changes to Laravel’s TestCase, RefreshDatabase, or Migrate traits are required. The package only modifies how `vendor/bin/phpunit` parses arguments, leaving everything else intact.
Can I use `file::method` syntax alongside Laravel’s existing `--filter` flag?
No, you must choose one or the other. This package translates `file::method` into `--filter` under the hood, so mixing both will cause conflicts. Use `phpunit tests/UserTest.php::testLogin` instead of `phpunit --filter testLogin`.
Will this break static analysis tools like Psalm or PHPStan?
Potentially, as these tools may not recognize `file::method` syntax. Mitigate this by adding `// @phpstan-ignore-line` or configuring your tool to ignore the transformed arguments. The package itself doesn’t affect static analysis beyond argument parsing.
How does this interact with PestPHP, which Laravel now recommends for testing?
This package works *only* with PHPUnit, not Pest. If you’re using Pest, leverage its native syntax (e.g., `php artisan pest --test UserTest::testLogin`). For PHPUnit-based tests, this package adds the `file::method` convenience without replacing Pest.
What if my test method names contain colons (e.g., `testUser::login()`)?
Avoid colons in test method names to prevent conflicts with the `file::method` syntax. If you must use colons, escape them or rename methods. The package doesn’t support nested colons in method names for clarity and reliability.
Does this work in CI/CD pipelines like GitHub Actions or Laravel Forge?
Yes, it requires no pipeline modifications. Install via Composer in your `composer.json` dev dependencies, and the syntax will work out of the box in Forge, Envoyer, GitHub Actions, or CircleCI without additional configuration.
Can I run multiple test methods at once (e.g., `UserTest.php::testLogin UserTest.php::testLogout`)?
Absolutely. The package supports multiple `file::method` arguments in a single command. Example: `vendor/bin/phpunit tests/UserTest.php::testLogin tests/UserTest.php::testLogout` will run both methods.
Is there any risk of breaking existing test suites or Laravel features?
No risk. The package only extends functionality—existing `--filter` syntax and all Laravel testing features (e.g., Eloquent, API tests, Dusk) remain fully functional. It’s a drop-in enhancement with zero architectural impact.
How do I install this in a Laravel project?
Run `composer require --dev sanmai/phpunit-double-colon-syntax` in your project root. No additional configuration is needed. The package hooks into `vendor/bin/phpunit` automatically, so you can start using `file::method` syntax immediately.
Are there alternatives for Laravel developers who want `file::method` syntax?
If you’re using PestPHP, it natively supports `UserTest::testLogin` syntax without this package. For PHPUnit users, alternatives include custom scripts or tools like `phpunit --filter`, but this package provides the closest match to pytest/Jest conventions with zero setup.
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.
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope
anil/file-picker
broqit/fields-ai