Completed
Push — master ( 048f0c...ea048a )
by Mahmoud
03:46
created

DeleteUserTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 40
Duplicated Lines 32.5 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 13
loc 40
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testDeleteExistingUser_() 0 15 1
A testDeleteAnotherExistingUser_() 13 13 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace App\Containers\User\UI\API\Tests\Functional;
4
5
use App\Containers\User\Models\User;
6
use App\Containers\User\Tests\TestCase;
7
8
/**
9
 * Class DeleteUserTest.
10
 *
11
 * @author Mahmoud Zalt <[email protected]>
12
 */
13
class DeleteUserTest extends TestCase
14
{
15
16
    protected $endpoint = 'delete@users/{id}';
17
18
    protected $access = [
19
        'roles'       => '',
20
        'permissions' => 'delete-users',
21
    ];
22
23
    public function testDeleteExistingUser_()
24
    {
25
        $user = $this->getTestingUser();
26
27
        // send the HTTP request
28
        $response = $this->injectId($user->id)->makeCall();
29
30
        // assert response status is correct
31
        $this->assertEquals('202', $response->getStatusCode());
32
33
        // assert the returned message is correct
34
        $this->assertResponseContainKeyValue([
35
            'message' => 'User (' . $user->id . ') Deleted Successfully.',
36
        ], $response);
37
    }
38
39 View Code Duplication
    public function testDeleteAnotherExistingUser_()
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...
40
    {
41
        // make the call form the user token who has no access
42
        $this->getTestingUserWithoutAccess();
43
44
        $anotherUser = factory(User::class)->create();
45
46
        // send the HTTP request
47
        $response = $this->injectId($anotherUser->id)->makeCall();
48
49
        // assert response status is correct
50
        $this->assertEquals('500', $response->getStatusCode());
51
    }
52
}
53