assertStatus(200); $response->assertSee('Email:'); $response->assertSee('Password:'); $response->assertSee('Войти'); }); it('can authenticate a user', function () { $user = User::factory()->create([ 'password' => bcrypt('password123'), ]); $response = post('/login', [ 'email' => $user->email, 'password' => 'password123', ]); $response->assertRedirect('/dashboard'); expect(auth()->check())->toBeTrue(); }); it('cannot authenticate a user with invalid credentials', function () { $user = User::factory()->create([ 'password' => bcrypt('password123'), ]); $response = post('/login', [ 'email' => $user->email, 'password' => 'wrongpassword', ]); $response->assertSessionHasErrors(); expect(auth()->check())->toBeFalse(); }); it('can logout a user', function () { $user = User::factory()->create(); $response = $this->actingAs($user)->post('/logout'); $response->assertRedirect('/'); expect(auth()->check())->toBeFalse(); });