Running PHPUnit
First, we can verify that we have set up correctly by executing the phpunit
command. There are no tests yet, but that’s okay. This step just verifies that the tool is installed and our configuration file is properly read.
How to do it…
Consult the documentation
From here, we are going to provide bare-bones, verbose commands to use PHPUnit to execute tests. If you use Lando, DDEV, Docksal, or otherwise, please consult their documentation on how to best run PHPUnit. They usually have command wrappers that are small and convenient.
In your command line, execute the following:
phpunit
This is the main command you will run. PHPUnit will automatically detect our phpunit.xml
configuration in the project directory.
Can’t find phpunit?
If you get an error about the phpunit
command not being found, you may need to instead use the full path to it from the project root with vendor/bin/phpunit
. Composer should automatically alias commands...