Code Duplication    Length = 26-28 lines in 2 locations

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

@@ 48-73 (lines=26) @@
45
        $this->assertEquals($data['roles_ids'][0], $responseContent->data->roles->data[0]->id);
46
    }
47
48
    public function testAssignUserToRoleWithRealId_()
49
    {
50
        $randomUser = factory(User::class)->create();
51
52
        $role = factory(Role::class)->create();
53
54
        $data = [
55
            'roles_ids' => [$role->id], // testing against real ID's
56
            'user_id'   => $randomUser->id, // testing against real ID's
57
        ];
58
59
        // send the HTTP request
60
        $response = $this->makeCall($data);
61
62
        // assert response status is correct. Note: this will return 200 if `HASH_ID=false` in the .env
63
        if(\Config::get('hello.hash-id')){
64
            $this->assertEquals('400', $response->getStatusCode());
65
66
            $this->assertResponseContainKeyValue([
67
                'message' => 'Only Hashed ID\'s allowed (user_id).',
68
            ], $response);
69
        }else{
70
            $this->assertEquals('200', $response->getStatusCode());
71
        }
72
73
    }
74
75
    public function testAssignUserToManyRoles_()
76
    {

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

@@ 52-79 (lines=28) @@
49
        ]);
50
    }
51
52
    public function testRevokeUserFromRoleWithRealId_()
53
    {
54
        $roleA = factory(Role::class)->create();
55
56
        $randomUser = factory(User::class)->create();
57
        $randomUser->assignRole($roleA);
58
59
        $data = [
60
            'roles_ids' => [$roleA->id],
61
            'user_id'   => $randomUser->id,
62
        ];
63
64
        // send the HTTP request
65
        $response = $this->makeCall($data);
66
67
68
        // assert response status is correct. Note: this will return 200 if `HASH_ID=false` in the .env
69
        if(\Config::get('hello.hash-id')){
70
            $this->assertEquals('400', $response->getStatusCode());
71
72
            $this->assertResponseContainKeyValue([
73
                'message' => 'Only Hashed ID\'s allowed (roles_ids.*).',
74
            ], $response);
75
        }else{
76
            $this->assertEquals('200', $response->getStatusCode());
77
        }
78
79
    }
80
81
    public function testRevokeUserFromManyRoles_()
82
    {