3

I get the following error when I run phpunit with Laravel 4.

PHP Fatal error:  Class 'Illuminate\Foundation\Testing\TestCase' not found in 

composer.json

    "require": {
    "laravel/framework": "4.0.*",
    "phpunit/phpunit": "3.7.*"
},

app.php

   'Illuminate\Foundation\Testing\TestCase'

What ı should do?

kemal
  • 371
  • 2
  • 4
  • 14
  • You have not shown how you run PHPUnit. You have not shown how you've configured PHPUnit. See as well [Laravel 4 migrations - class not found](http://stackoverflow.com/q/14069586/367456) which might not solve your issue but probably does. – hakre Aug 12 '13 at 05:24

3 Answers3

3

It looks like the autoload doesn't include the new requirement.

Be sure to run composer update to ensure that the file are downloaded and the autoloader is updated with that source.

If the files were downloaded and 'installed' manually run php composer dump-autoload to rebuild the autoload file.

pbond
  • 1,888
  • 4
  • 19
  • 35
Tim F
  • 349
  • 1
  • 12
2

I just ran into the same problem, so I thought I'd post my solution, even though it might be a different solution to what you were after.

I wanted to autoload my own libraries, so I added the following to my composer.json:

"autoload": {
    "psr-0": {
        "Fhc": "app"
    }
},

What I didn't realise was that just above that line was the following:

"autoload": {
    "classmap": [
        "app/commands",
        "app/controllers",
        "app/models",
        "app/database/migrations",
        "app/database/seeds",
        "app/tests/TestCase.php"
    ],
},

In essence, my modification had completely overridden the the code above. The solution was to merge the two together (as I should have done to begin with).

"autoload": {
    "classmap": [
        "app/commands",
        "app/controllers",
        "app/models",
        "app/database/migrations",
        "app/database/seeds",
        "app/tests/TestCase.php"
    ],
    "psr-0": {
        "Fhc": "app"
    }
},

Now it's all working as expected.

I hope this helps anyone else in the same situation.

thefuzzy0ne
  • 479
  • 3
  • 10
0

Try to remove your "vendor" folder and the file named composer.lock after that run:

composer install

Pay attention to the output produced by composer.

emont01
  • 3,010
  • 1
  • 22
  • 18