I am late to the party though. But as personal I hate to write the whole line.
Instead, I use the following shortcuts in the .bash_profile file make sure to source .bash_profile the file after adding any new alias else it won't work.
alias pa="php artisan"
alias pu="vendor/bin/phpunit"
alias puf="vendor/bin/phpunit --filter"
Usage:
puf function_name
puf filename
If you use Visual Studio Code you can use the following package to make your tests breeze.
Package Name: Better PHPUnit
Link: https://marketplace.visualstudio.com/items?itemName=calebporzio.better-phpunit
You can then set the keybinding in the settings. I use Command + T binding in my MAC.
Now once you place your cursor on any function and then use the key binding then it will automatically run that single test.
If you need to run the whole class then place the cursor on top of the class and then use the key binding.
If you have any other things then always tweek with the Terminal
Happy Coding!