create(['email' => 'test@test.com']); postJson(action(LoginController::class), [ 'email' => 'test@test.com', 'password' => 'password', 'device_name' => 'Feature test', ]) ->assertCreated() ->assertJsonStructure(['data' => ['token']]); assertCount(1, $user->refresh()->tokens); }); test('bad login should return HTTP 400', function () { postJson(action(LoginController::class), [ 'email' => 'test@test.com', 'password' => 'password', 'device_name' => 'Feature test', ]) ->assertStatus(400) ->assertJsonPath('message', 'Invalid credentials.') ->assertJsonPath('code', 'BAD_LOGIN'); });