create(); $response = $this->postJson('/api/v1/auth/login', [ 'email' => $user->email, 'password' => 'password', ]); $response->assertOk() ->assertJsonStructure([ 'success', 'data' => ['user' => ['id', 'name', 'email'], 'token'], 'message', ]) ->assertJson(['success' => true]); } public function test_login_fails_with_invalid_credentials(): void { $user = User::factory()->create(); $response = $this->postJson('/api/v1/auth/login', [ 'email' => $user->email, 'password' => 'wrong-password', ]); $response->assertUnauthorized(); } public function test_login_requires_email_and_password(): void { $response = $this->postJson('/api/v1/auth/login', []); $response->assertUnprocessable() ->assertJsonValidationErrors(['email', 'password']); } }