mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 12:33:56 +00:00
46 lines
1.3 KiB
PHP
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);
|
|
}
|
|
}
|