Code Duplication    Length = 27-29 lines in 2 locations

app/Containers/Authorization/UI/API/Tests/Functional/AttachPermissionsToRoleTest.php 1 location

@@ 24-50 (lines=27) @@
21
        'permissions' => '',
22
    ];
23
24
    public function testAttachSinglePermissionToRole_()
25
    {
26
        $this->getTestingAdmin();
27
28
        $roleA = factory(Role::class)->create();
29
        $permissionA = factory(Permission::class)->create();
30
31
        $data = [
32
            'role_id'         => $roleA->getHashedKey(),
33
            'permissions_ids' => $permissionA->getHashedKey(),
34
        ];
35
36
        // send the HTTP request
37
        $response = $this->apiCall($this->endpoint, 'post', $data, true);
38
39
        // assert response status is correct
40
        $this->assertEquals('200', $response->getStatusCode());
41
42
        $responseObject = $this->getResponseObject($response);
43
44
        $this->assertEquals($roleA['name'], $responseObject->data->name);
45
46
        $this->seeInDatabase('role_has_permissions', [
47
            'permission_id' => $permissionA->id,
48
            'role_id'       => $roleA->id
49
        ]);
50
    }
51
52
    public function testAttachMultiplePermissionToRole_()
53
    {

app/Containers/Authorization/UI/API/Tests/Functional/DetachPermissionsFromRoleTest.php 1 location

@@ 24-52 (lines=29) @@
21
        'permissions' => '',
22
    ];
23
24
    public function testDetachSinglePermissionFromRole_()
25
    {
26
        $this->getTestingAdmin();
27
28
        $permissionA = factory(Permission::class)->create();
29
30
        $roleA = factory(Role::class)->create();
31
        $roleA->givePermissionTo($permissionA);
32
33
        $data = [
34
            'role_id'         => $roleA->getHashedKey(),
35
            'permissions_ids' => $permissionA->getHashedKey(),
36
        ];
37
38
        // send the HTTP request
39
        $response = $this->apiCall($this->endpoint, 'post', $data, true);
40
41
        // assert response status is correct
42
        $this->assertEquals('200', $response->getStatusCode());
43
44
        $responseObject = $this->getResponseObject($response);
45
46
        $this->assertEquals($roleA->name, $responseObject->data->name);
47
48
        $this->missingFromDatabase('role_has_permissions', [
49
            'permission_id' => $permissionA->id,
50
            'role_id'       => $roleA->id
51
        ]);
52
    }
53
54
    public function testDetachMultiplePermissionFromRole_()
55
    {