{"action":"created","issue":{"url":"https://api.github.com/repos/laravel/framework/issues/8547","labels_url":"https://api.github.com/repos/laravel/framework/issues/8547/labels{/name}","comments_url":"https://api.github.com/repos/laravel/framework/issues/8547/comments","events_url":"https://api.github.com/repos/laravel/framework/issues/8547/events","html_url":"https://github.com/laravel/framework/issues/8547","id":70733464,"number":8547,"title":"[BUG][Lumen] Unit test with migrations: Class config does not exist","user":{"login":"KarimGeiger","id":2329930,"avatar_url":"https://avatars.githubusercontent.com/u/2329930?v=3","gravatar_id":"","url":"https://api.github.com/users/KarimGeiger","html_url":"https://github.com/KarimGeiger","followers_url":"https://api.github.com/users/KarimGeiger/followers","following_url":"https://api.github.com/users/KarimGeiger/following{/other_user}","gists_url":"https://api.github.com/users/KarimGeiger/gists{/gist_id}","starred_url":"https://api.github.com/users/KarimGeiger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KarimGeiger/subscriptions","organizations_url":"https://api.github.com/users/KarimGeiger/orgs","repos_url":"https://api.github.com/users/KarimGeiger/repos","events_url":"https://api.github.com/users/KarimGeiger/events{/privacy}","received_events_url":"https://api.github.com/users/KarimGeiger/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":13,"created_at":"2015-04-24T16:29:25Z","updated_at":"2015-05-22T12:06:38Z","closed_at":"2015-04-29T19:23:20Z","body":"I'm trying to setup unit tests for my Lumen application. Sadly, that only works well for the first test. So I'm assuming Lumen doesn't refresh correctly.\r\nHave a look at my TestCase class:\r\n\r\n    public function createApplication()\r\n    {\r\n        return require __DIR__ . '/../bootstrap/app.php';\r\n    }\r\n\r\n    public function artisanMigrateRefresh()\r\n    {\r\n        Artisan::call('migrate');\r\n    }\r\n\r\n    public function artisanMigrateReset()\r\n    {\r\n        Artisan::call('migrate:reset');\r\n    }\r\n\r\nWhen running a test, I'm setting up the database using:\r\n\r\n    public function setUp()\r\n    {\r\n        parent::setUp();\r\n        $this->artisanMigrateRefresh();\r\n    }\r\n\r\n    public function tearDown()\r\n    {\r\n        $this->artisanMigrateReset();\r\n        parent::tearDown();  // Moving that call to the top of the function didn't work either.\r\n    }\r\n\r\nThis works well for the first test. The second test fails, saying \"ReflectionException: Class config does not exist\" ([Full error trace](http://laravel.io/bin/wJaY4)).\r\n\r\nI've tried loading Lumen once for all tests (just for clarification), and that kind of worked, but as you may have guessed it just made things worse.\r\n\r\nThe migration (and call) itself works.. I've adjusted the phpunit.xml to use a sqlite memory-database:\r\n\r\n    <env name=\"DB_CONNECTION\" value=\"sqlite\"/>\r\n    <env name=\"DB_DATABASE\" value=\":memory:\"/>\r\n\r\nTo reproduce this behaviour, have a look at my [test repository](https://github.com/KarimGeiger/lumen-unittest). Just check it out, run composer update and then run phpunit. You will see the test failing.\r\nRemove the second test at tests/ExampleTest.php, run phpunit again and it will succeed.\r\n\r\nThings I've done:\r\n* Extended tests as described.\r\n* Added a migration-script.\r\n* Let the main page create and fetch something from the database (to test that this actually working).\r\n* Enabled Facades.\r\n\r\n(See the [forum post](http://laravel.io/forum/04-22-2015-lumen-problem-with-migrations-in-unit-tests-class-config-does-not-exist) for additional information)"},"comment":{"url":"https://api.github.com/repos/laravel/framework/issues/comments/104644877","html_url":"https://github.com/laravel/framework/issues/8547#issuecomment-104644877","issue_url":"https://api.github.com/repos/laravel/framework/issues/8547","id":104644877,"user":{"login":"neylsongularte","id":4109823,"avatar_url":"https://avatars.githubusercontent.com/u/4109823?v=3","gravatar_id":"","url":"https://api.github.com/users/neylsongularte","html_url":"https://github.com/neylsongularte","followers_url":"https://api.github.com/users/neylsongularte/followers","following_url":"https://api.github.com/users/neylsongularte/following{/other_user}","gists_url":"https://api.github.com/users/neylsongularte/gists{/gist_id}","starred_url":"https://api.github.com/users/neylsongularte/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/neylsongularte/subscriptions","organizations_url":"https://api.github.com/users/neylsongularte/orgs","repos_url":"https://api.github.com/users/neylsongularte/repos","events_url":"https://api.github.com/users/neylsongularte/events{/privacy}","received_events_url":"https://api.github.com/users/neylsongularte/received_events","type":"User","site_admin":false},"created_at":"2015-05-22T12:06:38Z","updated_at":"2015-05-22T12:06:38Z","body":"Work for me as a palliative solution."}}