AuthControllerTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 24
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A testLoginWithValidCredentials() 0 18 1
1
<?php
2
3
namespace Tests\Feature;
4
5
use App\Models\Employee;
6
use Tests\AuthenticatedTestCase;
7
use Illuminate\Foundation\Testing\DatabaseMigrations;
8
9
class AuthControllerTest extends AuthenticatedTestCase
10
{
11
    use DatabaseMigrations;
12
13
    protected $authUri = 'api/v1/backoffice/login';
14
15
    public function testLoginWithValidCredentials()
16
    {
17
        // We create one new employee and save it on the database
18
        $user = factory(Employee::class)->create();
19
        $user->password = 'teste123';
20
21
        // When we try to login with his credentials
22
        $credentials = [
23
            'login' => $user->email,
24
            'password' => $user->password,
25
        ];
26
27
        $response = $this->json('POST', $this->authUri, $credentials);
28
29
        // It should return a JWT token
30
        $response
31
            ->assertStatus(200)
32
            ->assertJsonStructure([ 'token' ]);
33
    }
34
}
35