mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-08-17 00:51:04 +02:00
Fix and complete unit tests
This commit is contained in:
@ -35,6 +35,7 @@ class UserTest extends TestCase
|
||||
'name' => 'testCreate',
|
||||
'email' => 'testCreate@example.org',
|
||||
'password' => 'test',
|
||||
'password_confirmation' => 'test',
|
||||
]);
|
||||
|
||||
$response->assertStatus(200)
|
||||
@ -44,6 +45,42 @@ class UserTest extends TestCase
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* test User creation with missing values via API
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function testUserCreationWithMissingValues()
|
||||
{
|
||||
$response = $this->json('POST', '/api/register', [
|
||||
'name' => '',
|
||||
'email' => '',
|
||||
'password' => '',
|
||||
'password_confirmation' => '',
|
||||
]);
|
||||
|
||||
$response->assertStatus(400);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* test User creation with invalid values via API
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function testUserCreationWithInvalidData()
|
||||
{
|
||||
$response = $this->json('POST', '/api/register', [
|
||||
'name' => 'testInvalid',
|
||||
'email' => 'email',
|
||||
'password' => 'test',
|
||||
'password_confirmation' => 'tset',
|
||||
]);
|
||||
|
||||
$response->assertStatus(400);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* test User login via API
|
||||
*
|
||||
@ -63,6 +100,41 @@ class UserTest extends TestCase
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* test User login with missing values via API
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function testUserLoginWithMissingValues()
|
||||
{
|
||||
$response = $this->json('POST', '/api/login', [
|
||||
'email' => '',
|
||||
'password' => ''
|
||||
]);
|
||||
|
||||
$response->assertStatus(400);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* test User login with invalid credentials via API
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function testUserLoginWithInvalidCredential()
|
||||
{
|
||||
$response = $this->json('POST', '/api/login', [
|
||||
'email' => $this->user->email,
|
||||
'password' => 'badPassword'
|
||||
]);
|
||||
|
||||
$response->assertStatus(401)
|
||||
->assertJson([
|
||||
'error' => 'Unauthorised'
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* test User logout via API
|
||||
*
|
||||
|
Reference in New Issue
Block a user