Files
exchange-2.0/tests/Feature/Accounts/UserAuthenticationControllerTest.php
T
2023-10-30 22:07:08 +08:00

46 lines
1.3 KiB
PHP

<?php
namespace Tests\Feature\Accounts;
use App\Models\User;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class UserAuthenticationControllerTest extends TestCase
{
use DatabaseMigrations;
public function test_existing_user_login()
{
// create a user
$response = $this->postJson(route('api.account.registration.register', [
"company_name" => "",
"name" => "user one",
"email" => "user1@mail.com",
"password" => "password",
"password_confirmation" => "password",
"phone" => "0123456789",
"type" => 0
]));
$response = $this->postJson(route('api.account.authentication.authenticate.attempt', [
'email' => 'user1@mail.com',
'password' => 'password'
]));
$response->assertStatus(200);
}
public function test_non_existing_user_login()
{
$response = $this->postJson(route('api.account.authentication.authenticate.attempt', [
'email' => 'user2@mail.com',
'password' => 'password'
]));
$response->assertStatus(401);
}
}