Initial commit
This commit is contained in:
43
tests/Feature/Auth/LoginControllerTest.php
Normal file
43
tests/Feature/Auth/LoginControllerTest.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Auth;
|
||||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class LoginControllerTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_login_success_returns_user(): void
|
||||
{
|
||||
$user = $this->createUser([
|
||||
'password' => 'demodemo',
|
||||
]);
|
||||
|
||||
$response = $this->withSession([])->postJson('/api/login', [
|
||||
'email' => $user->email,
|
||||
'password' => 'demodemo',
|
||||
]);
|
||||
|
||||
$response->assertStatus(200)
|
||||
->assertJsonFragment([
|
||||
'id' => $user->id,
|
||||
'email' => $user->email,
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_login_inactive_user_fails(): void
|
||||
{
|
||||
$user = $this->createInactiveUser([
|
||||
'password' => 'demodemo',
|
||||
]);
|
||||
|
||||
$response = $this->withSession([])->postJson('/api/login', [
|
||||
'email' => $user->email,
|
||||
'password' => 'demodemo',
|
||||
]);
|
||||
|
||||
$response->assertStatus(422);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user