init(); $this->withoutExceptionHandling(); $user = User::factory()->create(['email' => 'mail@example.com', 'password' => Hash::make('secret')]); $this->post('/login', [ 'email' => 'mail@example.com', 'provider' => 'database', 'password' => 'secret' ]); $key = session()->get('auth_key'); $cache = Cache::get("namiauth-{$key}"); $this->assertEquals($user->id, data_get($cache, 'id')); $this->assertTrue(auth()->check()); } public function testItThrowsExceptionWhenLoginFailed(): void { $this->init(); $user = User::factory()->create(['email' => 'mail@example.com', 'password' => Hash::make('secret')]); $this->post('/login', [ 'email' => 'mail@example.com', 'provider' => 'database', 'password' => 'wrong' ])->assertRedirect('/'); $this->assertFalse(auth()->check()); } }