问题
I have a pretty basic Laravel setup that I am starting to test. I have my own library files in the folder app/framework and all the files are under the namespace "CompanyName\Framework". I added these files to the composer.json file to have it autoloaded in my app.
My composer.json is then :
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php",
"app/framework"
]
In my controller I can use my library fine and autoloading seems to work. When I try to test that controller in my unit test it says
....PHP Fatal error: Class 'CompanyName\Framework\DatabaseUpdater' not found in C:\ Production\CompanyName\laravel\app\controllers\DatabaseController.php on line 19
Why is that namespace suddently invalid when I call my controller from my unit test ? The unit test itself is very basic, it is simply a $this->client->request('GET', '/'). Absolutely everything works perfectly except the unit test.
来源:https://stackoverflow.com/questions/22517218/laravel-unit-tests-cannot-find-namespaced-class