Unable to run phpunit to test laravel on Windows 10 - windows

I have laravel 5.1 installed on a windows 10 machine. Laravel 5.1 comes pre installed with phpunit
I can see that it exist in vendor\bin directory - both phpunit and phpunit.bat
When I run the phpunit command from from the root of my laravel project I get the following error:
phpunit
Cannot run program "phpunit" (in directory "C:\wamp\www\laravel\myproject"): CreateProcess error=2, The system cannot find the file specified
I tried the following vendor/bin/phpunit and i get the following error:
vendor/bin/phpunit
Cannot run program "C:\wamp\www\laravel\leavetracker-5.1\vendor\bin\phpunit" (in directory "C:\wamp\www\laravel\myproject"): CreateProcess error=193, %1 is not a valid Win32 application
I've attempted to add phpunit as a environment variable aswell but it still doesnt work:
C:\wamp\www\laravel\myproject\vendor\bin;

As discussed in the comment, you can execute the command as follow:
> vendor/bin/phpunit.bat
Check the php.ini config files for correct configuration of the CLI, executing the command:
> php -i
An search for php.ini string.

This is what i use on windows 10
C:\code\laravel-project> vendor\bin\phpunit

Related

Cannot open file "/tests/ExampleTest.php" Laravel5 using Windows10

i am running phpunit testing in laravel5 on windows 10,and getting this error by running the following command.
Cannot open file "/tests/ExampleTest.php",
D:\wamp64\www\forum\vendor\bin>phpunit /tests/ ExampleTest.php
Can you please suggest me what could be the issue?
Its seems that "phpunit" is not installed globally,try run this command from cli to install it globally and then you can use unit testing globally.
"composer global require phpunit/phpunit"

How do I get phpunit to work in cloud9 IDE?

Just started out a laravel project on cloud9 IDE but I can't get phpunit to work. Every time I run the PHPUnit command I get a
command not found
response. From the file structure in the project I can see phpunit files. I have never used cloud 9 for a laravel project before so I can't really tell if thats how it's supposed to behave. Has anyone successfully used phpunit on cloud9 before?
You can install phpunit globally using composer (available in the default C9 workspace). Phpunit 4.8.* works with PHP 5.5.
sudo composer global require phpunit/phpunit:4.8.*
The phpunit executable will be installed in ~/.composer/vendor/bin/ so add the following line at the end of the ~/.profile file to make the command available elsewhere.
export PATH=~/.composer/vendor/bin:$PATH
Run source ~/.profile afterwards to register the new path then simply run phpunit in your Laravel installation folder.

bash configuration error : No such file or directory

i am trying to run tests using phpunit from a directory with the following path:
/home/rally/adserver/test/ by using the command phpunit classes/AdTest.php,
The command was working in previous times when i cloned the project but now for some reason after using git clone and composer install today i get this error:
bash: /home/rally/tests/adserver/src/vendor/bin/phpunit: No such file or directory
any help with how can i fix this or what is causing this? thx

Laravel installer are inside .composer/vendor/bin directory and I tried to run laravel command but it gives error

Laravel installer are inside .composer/vendor/bin directory and I tried to run Laravel command but it gives error "sh: 22: Laravel: not found"
I am using Ubuntu as a OS.
You have to add composer bin dir to your PATH environment variable.
export PATH="$PATH:~/.composer/vendor/bin"

Using phpunit in laravel 4 without /vendor/bin/

I have installed phpunit in this instance of laravel using composer. The files are present in the laravel/vendor/bin folder. when I run vendor/bin/phpunit the example test runs. In all the tutorials I am watching on unit testing in laravel the tutors simply run phpunit and it runs the test.
In the laravel documentation it says that I should be able to simply run phpunit to initiate the tests.
Is the documentation refering to phpunit being installed system wide and do the tutors in the video simply have it installed system wide or am I missing something?
In linux, get phpunit path by typing which phpunit in the terminal. Its probably in the /usr/bin/ dir. execute
alias phpunit='/usr/bin/phpunit'
in the terminal.
They have it installed system wide.
If you are in Windows, you can modify your PATH system variable to include the path to phpunit. For example on mine, I've appended ;C:\wamp\www\rel\vendor\bin to it.
Then you'd just have to navigate to the folder your project is in which should have the phpunit.xml file that was included with laravel and run phpunit on your command prompt.
Unfortunately, I am not completely sure how to do this on Linux or OSX.
In Mac OS, just go to your Laravel project directory via Terminal and then enter this command:
alias phpunit="~/Your Project Directory Name/vendor/bin/phpunit"
From now on you can run PHPUnit by just simply typing phpunit.

Resources