Completed
Push — master ( 563d71...071fd8 )
by Mahmoud
03:32
created

CreateAdminTest::testCreateAdmin_()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 32
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 32
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 16
nc 1
nop 0
1
<?php
2
3
namespace App\Containers\User\UI\API\Tests\Functional;
4
5
use App\Port\Tests\PHPUnit\Abstracts\TestCase;
6
7
/**
8
 * Class CreateAdminTest.
9
 *
10
 * @author Mahmoud Zalt <[email protected]>
11
 */
12
class CreateAdminTest extends TestCase
13
{
14
15
    private $endpoint = '/admins/create';
16
17
    public function testCreateAdmin_()
18
    {
19
20
        $admin = $this->getLoggedInTestingAdmin();
0 ignored issues
show
Unused Code introduced by
$admin is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
21
22
        $data = [
23
            'email'    => '[email protected]',
24
            'name'     => 'admin',
25
            'password' => 'secret',
26
        ];
27
28
        // send the HTTP request
29
        $response = $this->apiCall($this->endpoint, 'post', $data);
30
31
        // assert response status is correct
32
        $this->assertEquals($response->getStatusCode(), '200');
33
34
        $this->assertResponseContainKeyValue([
35
            'email' => $data['email'],
36
            'name'  => $data['name'],
37
        ], $response);
38
39
         // assert response contain the token
40
        $this->assertResponseContainKeys(['id', 'token'], $response);
41
42
         // assert the data is stored in the database
43
        $this->seeInDatabase('users', ['email' => $data['email']]);
44
45
        $responseObject = $this->getResponseObject($response);
46
47
        $this->assertEquals($responseObject->data->roles->data[0]->name, $data['name']);
48
    }
49
50
}
51