Completed
Push — master ( 7ff671...be21d3 )
by Mahmoud
03:25
created

UpdateUserTest::testUpdateExistingUser_()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 24
Code Lines 12

Duplication

Lines 24
Ratio 100 %

Importance

Changes 0
Metric Value
dl 24
loc 24
rs 8.9713
c 0
b 0
f 0
cc 1
eloc 12
nc 1
nop 0
1
<?php
2
3
namespace App\Containers\User\UI\API\Tests\Functional;
4
5
use App\Containers\User\Tests\TestCase;
6
7
/**
8
 * Class UpdateUserTest.
9
 *
10
 * @author Mahmoud Zalt <[email protected]>
11
 */
12
class UpdateUserTest extends TestCase
13
{
14
15
    protected $endpoint = 'put@users';
16
17
    protected $access = [
18
        'roles'       => '',
19
        'permissions' => 'update-users',
20
    ];
21
22 View Code Duplication
    public function testUpdateExistingUser_()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
23
    {
24
        $user = $this->getTestingUser();
25
26
        $data = [
27
            'name'     => 'Updated Name',
28
            'password' => 'updated#Password',
29
        ];
30
31
        // send the HTTP request
32
        $response = $this->makeCall($data);
33
34
        // assert response status is correct
35
        $this->assertEquals('200', $response->getStatusCode());
36
37
        // assert returned user is the updated one
38
        $this->assertResponseContainKeyValue([
39
            'email' => $user->email,
40
            'name'  => $data['name'],
41
        ], $response);
42
43
        // assert data was updated in the database
44
        $this->seeInDatabase('users', ['name' => $data['name']]);
45
    }
46
47
    public function testUpdateExistingUserWithoutData_()
48
    {
49
        $data = [];
50
51
        // send the HTTP request
52
        $response = $this->makeCall($data);
53
54
        // assert response status is correct
55
        $this->assertEquals('417', $response->getStatusCode());
56
    }
57
58
59 View Code Duplication
    public function testUpdateExistingUserWithEmptyValues()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
60
    {
61
        $data = []; // empty data
62
63
        // send the HTTP request
64
        $response = $this->makeCall($data);
65
66
        // assert response status is correct
67
        $this->assertEquals('417', $response->getStatusCode());
68
69
        // assert message is correct
70
        $this->assertResponseContainKeyValue([
71
            'message' => 'Inputs are empty.',
72
        ], $response);
73
    }
74
}
75