Completed
Push — master ( fa7b60...6c1318 )
by Mahmoud
03:02
created

FindPermissionByNameTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 1
c 0
b 0
f 0
lcom 1
cbo 1
dl 23
loc 23
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A testGetPermission_() 16 16 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\Order\UI\API\Tests\Functional;
4
5
use App\Containers\Order\Models\Order;
6
use App\Containers\Invoice\Models\Invoice;
7
use App\Containers\User\Models\User;
8
use App\Port\Tests\PHPUnit\Abstracts\TestCase;
9
use Vinkla\Hashids\Facades\Hashids;
10
11
/**
12
 * Class FindPermissionByNameTest.
13
 *
14
 * @author  Mahmoud Zalt <[email protected]>
15
 */
16 View Code Duplication
class FindPermissionByNameTest extends TestCase
0 ignored issues
show
Duplication introduced by
This class 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...
17
{
18
19
    private $endpoint = '/find-permission';
20
21
    public function testGetPermission_()
22
    {
23
        $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...
24
25
        $data = ['name' => 'manage-roles-permissions'];
26
27
        // send the HTTP request
28
        $response = $this->apiCall($this->endpoint, 'get', $data, true);
29
30
        // assert response status is correct
31
        $this->assertEquals($response->getStatusCode(), '200');
32
33
        $responseObject = $this->getResponseObject($response);
34
35
        $this->assertEquals($data['name'], $responseObject->data->name);
36
    }
37
38
}
39