Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ;)

like image 480
Laurent Avatar asked Apr 08 '15 01:04

Laurent


People also ask

Why use PHPUnit?

PHPunit is mainly used for unit testing. When developer develops any web application, there might be chances of bugs coming into picture during the course of development. It is really hard to resolve one bug after another. PHPunit helps to reduce such types of bugs.

What is PHP artisan serve in Laravel?

The Laravel PHP artisan serve command helps running applications on the PHP development server. As a developer, you can use Laravel artisan serve to develop and test various functions within the application. It also accepts two additional options. You can use the host for changing application's address and port.


2 Answers

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
like image 112
Laurent Avatar answered Oct 04 '22 17:10

Laurent


This occurs when you don't have phpunit installed globally.

Run this command to use the local version (installed with composer):

vendor/bin/phpunit
like image 40
atul_systematix Avatar answered Oct 04 '22 17:10

atul_systematix