testLoginWithValidCredentials()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 9
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 18
rs 9.9666
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