sanmai / phpunit-double-colon-syntax
Double Colon Syntax for PHPUnit
Fund package maintenance!
sanmai
Requires
- php: >=7.1
Requires (Dev)
- brianium/paratest: ^7
- ergebnis/composer-normalize: ^2.8
- friendsofphp/php-cs-fixer: ^3.17
- infection/infection: >=0.30.3
- php-coveralls/php-coveralls: ^2.4.1
- phpstan/extension-installer: ^1.4
- phpstan/phpstan: ^2
- phpunit/phpunit: ^11 || ^12.2
- sanmai/phpstan-rules: ^0.3.7
This package is auto-updated.
Last update: 2025-07-22 08:09:11 UTC
README
Double Colon Syntax for PHPUnit
PHPUnit doesn't natively support the file::method
syntax commonly used in other testing frameworks, such as pytest (pytest test_file.py::test_method
). However, I found that AI assistants frequently suggest this syntax and even strongly believe this syntax is a thing (ChatGPT, Gemini, Claude), which is bonkers.
So it was always frustrating to see how an assistant generates a command using this syntax and fails, day after day, wasting time, tokens, context window, and my attention. Not anymore.
Now everyone can run individual test methods using the familiar file::method
syntax:
vendor/bin/phpunit tests/ExampleTest.php::testItWorks
But before...
Installation
composer require --dev sanmai/phpunit-double-colon-syntax
That's it! No configuration needed. Works with PHPUnit 6 and above.
Usage
It works with multiple methods:
vendor/bin/phpunit tests/ExampleTest.php::test_one tests/ExampleTest.php::test_two
It does not work with --filter
: you have to choose this or that syntax, not both.
How It Works
Uses Composer's autoloader to intercept and transform arguments before PHPUnit starts. The file::method
syntax becomes file --filter method
automatically. It targets specifically vendor/bin/phpunit
and ignores everything else.