ERP-API/tests/Feature/Auth/LoginTest.php

45 lines
951 B
PHP

<?php
namespace Tests\Feature\Auth;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;
use App\Models\User;
use Hash;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class LoginTest extends TestCase
{
use DatabaseTransactions;
/**
* A basic feature test example.
*/
public function test_success(): void
{
$user = User::factory()->create();
$response = $this->post('/auth/login',[
"email" => $user->email,
"password" => "password",
]);
$response->assertStatus(200);
}
/**
* A basic feature test example.
*/
public function test_fail(): void
{
$user = User::factory()->create();
$response = $this->post('/auth/login',[
"email" => $user->email,
"password" => "fail",
]);
$response->assertStatus(422);
}
}