PHPUnit not working with Laravel 5

 

I just installed a fresh Laravel 5 project, my first one on this version. PHPUnit is supposed to be out of the box with the framework and every tutorials I saw just say to type phpunit within the project folder to launch the Unit Tests.

I checked and PHPUnit is in the composer.json, I also did a composer install and composer update just in case it wouldn't be here

website(master)$ composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Removing phpunit/phpunit (4.6.1)
  - Installing phpunit/phpunit (4.6.2)
    Downloading: 100%

But it just doesn't work phpunit isn't recognized at all

 website(master)$ phpunit
-bash: phpunit: command not found

Seems like nobody got this problem before as I Googled it. I hope I'm not doing any stupid mistake. Any idea or suggestion ? Thanks guys ;)

share improve this question
 
5  
./vendor/bin/phpunit –  zerkms  Apr 8 '15 at 1:29
    
alright thank you, that was pretty stupid at the end but i'm sure some people would do the same ^^ –  Laurent  Apr 8 '15 at 1:37
1  
@Laurent it's not uncommon to have PHPUnit installed globally on your system so you can run phpunitfrom anywhere –  Phil  Apr 8 '15 at 1:43
    
Yeah I installed it globally and it works well now –  Laurent  Apr 8 '15 at 1:44

2 Answers

up vote 9 down vote accepted

I didn't install PHPUnit globally and didn't define the path. So for anyone who would have same problem :

composer global require phpunit/phpunit
composer global require phpunit/dbunit

Then you add this to you ~/.bash_profile or ~/.profile

export PATH=~/.composer/vendor/bin:$PATH
share improve this answer
 
    
It works , thanks . –  Chutipong Roobklom  Mar 2 at 16:03
 

Include this line on your composer.json

"phpunit/phpunit": "4.0.*",

Run composer update. You should be able to run the following command on your Laravel directory.

vendor/bin/phpunit 
share improve this answer

猜你喜欢

转载自xialluyouyue.iteye.com/blog/2286212