PHPUnit is a programmer-oriented testing framework for PHP. It is an instance of the xUnit architecture for unit testing frameworks.
Installation
homebrew
1. See what versions brew has
brew search phpunit2. Install that specific version of phpunit
brew install phpunit@5.73. Verify phpunit was installed
phpunitat57 —version
Commands
Click here to expand...
https://phpunit.de/getting-started.html
1. run phpunit test class
phpunit —bootstrap src/Email.php tests/EmailTest
- phpunit - invokes the PHPUnit command-line test runner. We assume that you have downloaded phpunit.phar (see above) and put it into your $PATH as phpunit.
- —bootstrap src/Email.php - instructs the PHPUnit command-line test runner to include src/Email.php before the test execution.
- Usually, though, you use —bootstrap to instruct the PHPUnit command-line test runner to include bootstrap script that sets up autoloading for the classes that are to be tested. Such a script is commonly generated using tools such as Composer or phpab.
- tests/EmailTest - instructs the PHPUnit command-line test runner to execute the tests of the EmailTest class that is declared in tests/EmailTest.php.
- Using tests instead of tests/EmailTest would instruct the PHPUnit command-line test runner to execute all tests found declared in *Test.php source code files in the tests directory.
2. for alternative output
phpunit —bootstrap src/Email.php —testdox tests