From 5ad60e27e4d94cf31a324f2a15859324bf19918c Mon Sep 17 00:00:00 2001 From: E98Developer Date: Wed, 6 May 2026 21:10:45 +0200 Subject: [PATCH] =?UTF-8?q?EV3-413=20Kil=C3=A9p=C3=A9skor=20azonos=20login?= =?UTF-8?q?=20oldara=20=C3=ADr=C3=A1ny=C3=ADt=C3=A1s=20ADD=20AdminLoginTes?= =?UTF-8?q?t?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/Feature/AdminLoginTest.php | 48 ++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 tests/Feature/AdminLoginTest.php diff --git a/tests/Feature/AdminLoginTest.php b/tests/Feature/AdminLoginTest.php new file mode 100644 index 0000000..ebe4d51 --- /dev/null +++ b/tests/Feature/AdminLoginTest.php @@ -0,0 +1,48 @@ + 'admin', 'display_name' => 'Admin', 'description' => 'Admin']); + $user = User::factory()->create([ + 'name' => 'testuser', + 'password' => bcrypt('password'), + ]); + $user->addRole($adminRole); + + Livewire::test(Login::class) + ->fillForm([ + 'name' => 'testuser', + 'password' => 'password', + ]) + ->call('authenticate') + ->assertHasNoFormErrors() + ->assertRedirect('/admin'); + + $this->assertAuthenticatedAs($user); +}); + +it('cannot login with email anymore', function () { + $user = User::factory()->create([ + 'name' => 'testuser', + 'email' => 'test@example.com', + 'password' => bcrypt('password'), + ]); + + Livewire::test(Login::class) + ->fillForm([ + 'email' => 'test@example.com', + 'password' => 'password', + ]) + ->call('authenticate') + ->assertHasFormErrors(['name']); + + $this->assertGuest(); +});