{"action":"created","issue":{"url":"https://api.github.com/repos/laravel/lumen-framework/issues/125","labels_url":"https://api.github.com/repos/laravel/lumen-framework/issues/125/labels{/name}","comments_url":"https://api.github.com/repos/laravel/lumen-framework/issues/125/comments","events_url":"https://api.github.com/repos/laravel/lumen-framework/issues/125/events","html_url":"https://github.com/laravel/lumen-framework/issues/125","id":84050122,"number":125,"title":"[BUG] Lumen Unit Test - Strange Behaviors","user":{"login":"hiraq","id":710299,"avatar_url":"https://avatars.githubusercontent.com/u/710299?v=3","gravatar_id":"","url":"https://api.github.com/users/hiraq","html_url":"https://github.com/hiraq","followers_url":"https://api.github.com/users/hiraq/followers","following_url":"https://api.github.com/users/hiraq/following{/other_user}","gists_url":"https://api.github.com/users/hiraq/gists{/gist_id}","starred_url":"https://api.github.com/users/hiraq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hiraq/subscriptions","organizations_url":"https://api.github.com/users/hiraq/orgs","repos_url":"https://api.github.com/users/hiraq/repos","events_url":"https://api.github.com/users/hiraq/events{/privacy}","received_events_url":"https://api.github.com/users/hiraq/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-06-02T14:33:12Z","updated_at":"2015-06-03T02:51:38Z","closed_at":null,"body":"Here my TestCase class:\r\n\r\n```php\r\n<?php\r\n\r\nuse Illuminate\\Support\\Facades\\Artisan;\r\nuse App\\Models\\User;\r\n\r\nclass TestCase extends Laravel\\Lumen\\Testing\\TestCase {\r\n\r\n    /**\r\n     * Creates the application.\r\n     *\r\n     * @return \\Laravel\\Lumen\\Application\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 setUp()\r\n    {\r\n        parent::setUp();\r\n        $this->refreshApplication();\r\n        Artisan::call('migrate');\r\n    }\r\n\r\n    public function tearDown()\r\n    {\r\n        Artisan::call('migrate:reset');\r\n    }\r\n\r\n}\r\n```\r\n\r\nAnd here my test scenario:\r\n\r\n```php\r\n<?php\r\n\r\nuse App\\Models\\User;\r\nuse App\\Models\\Observers\\User as UserObserver;\r\n\r\nclass UsersControllerTest extends TestCase {\r\n\r\n    public function testRegisterSuccess()\r\n    {\r\n        $params = [\r\n            'email' => 'test@test.com',\r\n            'password' => 'testing',\r\n            'password_confirmation' => 'testing'\r\n        ];\r\n\r\n        $response = $this->call('POST', '/api/v1/users/register', $params);\r\n        $json = json_decode($response->getContent()); \r\n\r\n        $this->assertResponseOk();\r\n        \r\n        /*\r\n         * check and test json response\r\n         */ \r\n        $this->assertTrue(isset($json->status));    \r\n        $this->assertTrue(isset($json->data));    \r\n        $this->assertEquals('success', $json->status); \r\n        $this->assertTrue(empty($json->data));\r\n\r\n        /*\r\n         * check and test database data\r\n         */\r\n        $user = User::where('email', 'test@test.com')->first();\r\n        $this->assertTrue(!empty($user));\r\n        $this->assertTrue(isset($user->email));\r\n        $this->assertEquals('test@test.com', $user->email);        \r\n    }\r\n\r\n    public function testRegisterFailedEmailExists()\r\n    {\r\n        $this->generateUser('test@test.com', 'testing');\r\n        \r\n        $params = [\r\n            'email' => 'test@test.com',\r\n            'password' => 'testing',\r\n            'password_confirmation' => 'testing'\r\n        ];\r\n\r\n        $response = $this->call('POST', '/api/v1/users/register', $params);\r\n        $this->assertResponseStatus(400);\r\n\r\n        $json = json_decode($response->getContent());\r\n        \r\n        $this->assertTrue(isset($json->status));\r\n        $this->assertEquals('error', $json->status);\r\n\r\n        $this->assertTrue(isset($json->message));\r\n        $this->assertEquals('Fail to validate.', $json->message);\r\n    }\r\n\r\n    public function testRegisterEmptyParams()\r\n    {\r\n        $response = $this->call('POST', '/api/v1/users/register', []);\r\n        $this->assertResponseStatus(400);\r\n\r\n        $json = json_decode($response->getContent());\r\n        \r\n        $this->assertTrue(isset($json->status));\r\n        $this->assertEquals('error', $json->status);\r\n\r\n        $this->assertTrue(isset($json->message));\r\n        $this->assertEquals('Fail to validate.', $json->message);\r\n    }\r\n\r\n    private function generateUser($email, $password)\r\n    {\r\n        User::observe(new UserObserver);\r\n        $user = new User;\r\n        $user->register($email, $password);\r\n    }\r\n}\r\n```\r\n\r\nWhen i run for each test like :\r\n\r\n```\r\n./vendor/bin/phpunit --filter testRegisterEmptyParams\r\n```\r\n\r\nIt works fine, here my screenshot :\r\n![lumen_test_empty_params](https://cloud.githubusercontent.com/assets/710299/7938241/bbcf1a56-096e-11e5-816c-5bcf4a93afe1.png)\r\n\r\nbut, when i run all tests :\r\n![lumen_all_tests](https://cloud.githubusercontent.com/assets/710299/7938260/d5a4935c-096e-11e5-9d0e-8e6c201bcd97.png)\r\n\r\nWhat happened here?\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/laravel/lumen-framework/issues/comments/108169895","html_url":"https://github.com/laravel/lumen-framework/issues/125#issuecomment-108169895","issue_url":"https://api.github.com/repos/laravel/lumen-framework/issues/125","id":108169895,"user":{"login":"hiraq","id":710299,"avatar_url":"https://avatars.githubusercontent.com/u/710299?v=3","gravatar_id":"","url":"https://api.github.com/users/hiraq","html_url":"https://github.com/hiraq","followers_url":"https://api.github.com/users/hiraq/followers","following_url":"https://api.github.com/users/hiraq/following{/other_user}","gists_url":"https://api.github.com/users/hiraq/gists{/gist_id}","starred_url":"https://api.github.com/users/hiraq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hiraq/subscriptions","organizations_url":"https://api.github.com/users/hiraq/orgs","repos_url":"https://api.github.com/users/hiraq/repos","events_url":"https://api.github.com/users/hiraq/events{/privacy}","received_events_url":"https://api.github.com/users/hiraq/received_events","type":"User","site_admin":false},"created_at":"2015-06-03T02:51:38Z","updated_at":"2015-06-03T02:51:38Z","body":"my users controller code:\r\n\r\n```php\r\n<?php namespace App\\Http\\Controllers;\r\n\r\nuse Request;\r\nuse Validator;\r\nuse App\\Models\\User;\r\nuse App\\Models\\Observers\\User as UserObserver;\r\n\r\nclass UsersController extends Controller {\r\n\r\n    public function postRegister()\r\n    {\r\n        $validate = Validator::make(Request::all(), [\r\n            'email' => 'required|email|unique:users,email',\r\n            'password' => 'required|confirmed',\r\n            'password_confirmation' => 'required'\r\n        ]);\r\n\r\n        if($validate->fails()) {\r\n            return $this->jsonable($validate->messages(), 'error', 400, 'Fail to validate.');\r\n        } else {\r\n\r\n            /*\r\n             * listening to user model\r\n             * on: creating, modify password, combine it with salt\r\n             *\r\n             * registering user data based on email and password\r\n             */\r\n            User::observe(new UserObserver); \r\n            $user = new User;\r\n            $user->register(Request::input('email'), Request::input('password'));\r\n            return $this->jsonable();\r\n        }\r\n    }\r\n\r\n    public function postLogin()\r\n    {\r\n\r\n    }\r\n}\r\n```"}}