3
votes

I create a laravel framework fresh copy from composer and when run on PHP Storm i m facing this error in PHP Storm

Fatal error: Class 'TestCase' not found in C:\xampp\htdocs\testproject\app\tests\ExampleTest.php on line 3

cd C:\xampp\htdocs\testproject Current working directory is 'C:\xampp\htdocs\testproject'.

phpunit

Cannot run program "phpunit" (in directory "C:\xampp\htdocs\testproject"): CreateProcess error=2, The system cannot find the file specified

3

3 Answers

2
votes

I had this problem in the past with Laravel 4 and 5. Turns out I was missing this in my composer.json.

Laravel 5:

"autoload-dev": {
    "classmap": [ "tests/TestCase.php" ]
},

Laravel 4:

"autoload-dev": {
    "classmap": [ "app/tests/TestCase.php" ]
},
0
votes

I think the way laravel is setup you need to be at the root of the specific project, then specify the rest to phpunit.

1.) alias phpunit='vendor/bin/phpunit'

Try changing your path to "C:\xampp\htdocs\testproject" then run "alias phpunit='vendor/bin/phpunit'" then run "phpunit app/tests/ExampleTest.php".

http://culttt.com/2013/05/20/getting-started-with-testing-laravel-4-models/

0
votes

You have to run the phpunit in the folder where You have your tests.

Run this from the command line, from the root directory of the project:

phpunit app/tests/