Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install PHPunit in a Laravel project

I'm trying to set up PHPunit in a Laravel project (which is being running in a Linux VM using Vagrant and VirtualBox). I've added PHPunit to composer.json and run composer install and composer update, and yet nothing is working. Running phpunit from the command line does nothing. (Nor does php phpunit or php phpunit.phar.)

How do I get PHPunit to run my tests?

like image 555
iconoclast Avatar asked Mar 21 '14 23:03

iconoclast


2 Answers

You must now run it using:

vendor/bin/phpunit
like image 154
Antonio Carlos Ribeiro Avatar answered Sep 28 '22 19:09

Antonio Carlos Ribeiro


Install phpunit globally and then can you can use it with just phpunit command in your local project instead of vendor/bin/phpunit (your composer/vendor/bin has to be in system path)

composer global require phpunit/phpunit

or you can add following alias in your VM and then you can run it within your project directory with just phpunit command

alias phpunit='vendor/bin/phpunit'
like image 27
Ali A. Dhillon Avatar answered Sep 28 '22 18:09

Ali A. Dhillon