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

前端 未结 3 880
Happy的楠姐
Happy的楠姐 2021-01-06 15:34

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

PHP Fatal error:  Class \'Illuminate\\Foundation\\Testing\\TestCase\' not found in 
3条回答
  •  不知归路
    2021-01-06 16:18

    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.

提交回复
热议问题