mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-07-11 01:24:46 +02:00
3ed878ab46
* fix: allow configurable domain and prefix for all supported routes * style: fix StyleCI finding
63 lines
1.3 KiB
PHP
63 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Feature\Actions\Fortify;
|
|
|
|
use App\Models\Auth\User;
|
|
use App\Providers\RouteServiceProvider;
|
|
use Tests\TestCase;
|
|
|
|
/**
|
|
* Class AuthenticationTest.
|
|
*/
|
|
class AuthenticationTest extends TestCase
|
|
{
|
|
/**
|
|
* Login screen can be rendered.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function testLoginScreenCanBeRendered(): void
|
|
{
|
|
$response = $this->get(route('login'));
|
|
|
|
$response->assertStatus(200);
|
|
}
|
|
|
|
/**
|
|
* Users can authenticate using the login screen.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function testUsersCanAuthenticateUsingTheLoginScreen(): void
|
|
{
|
|
$user = User::factory()->createOne();
|
|
|
|
$response = $this->post(route('login'), [
|
|
'email' => $user->email,
|
|
'password' => 'password',
|
|
]);
|
|
|
|
$this->assertAuthenticated();
|
|
$response->assertRedirect(RouteServiceProvider::HOME);
|
|
}
|
|
|
|
/**
|
|
* Users cannot authenticate with invalid password.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function testUsersCanNotAuthenticateWithInvalidPassword(): void
|
|
{
|
|
$user = User::factory()->createOne();
|
|
|
|
$this->post(route('login'), [
|
|
'email' => $user->email,
|
|
'password' => 'wrong-password',
|
|
]);
|
|
|
|
$this->assertGuest();
|
|
}
|
|
}
|