Install PHPunit with Composer
You can install PHPUnit as a local, per-project dependency with Composer. You can find more information in the PHPUnit's Github repo, you need put this dependency in the composer.json:
{
"require-dev": {
"phpunit/phpunit": "3.7.*"
}
}
Now you need update your dependencies:
composer update
It installs all PHPunit dependencies, and now you have a phpunit executable in [yourprojectdir]/vendor/bin/phpunit. If
for example you want to test the file SampleTest.php in the root of your project and you are in in the root of your project you can write in terminal:
vendor/bin/phpunit SampleTest.phpWritten by Juan
Related protips
1 Response
Nice tutorial for installing PHPUnit 3.7. I have found this article that details how to install PHPUnit 5.5 and using PHPUnit for unit testing PHP app.
Have a fresh tip? Share with Coderwall community!
PHP applications still send a browser full of JavaScript. Hardening the server does not inventory the payment, analytics, and plugin scripts that run after the HTML is delivered.
Security insights from Cside