Code Duplication    Length = 23-49 lines in 3 locations

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

@@ 16-38 (lines=23) @@
13
 *
14
 * @author  Mahmoud Zalt <[email protected]>
15
 */
16
class FindPermissionByNameTest extends TestCase
17
{
18
19
    private $endpoint = '/find-permission';
20
21
    public function testGetPermission_()
22
    {
23
        $admin = $this->getLoggedInTestingAdmin();
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

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

@@ 16-38 (lines=23) @@
13
 *
14
 * @author  Mahmoud Zalt <[email protected]>
15
 */
16
class FindRoleByNameTest extends TestCase
17
{
18
19
    private $endpoint = '/find-role';
20
21
    public function testGetRole_()
22
    {
23
        $admin = $this->getLoggedInTestingAdmin();
24
25
        $data = ['name' => 'admin'];
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

app/Containers/User/UI/API/Tests/Functional/RefreshUserTest.php 1 location

@@ 12-60 (lines=49) @@
9
 *
10
 * @author Mahmoud Zalt <[email protected]>
11
 */
12
class RefreshUserTest extends TestCase
13
{
14
15
    private $endpoint = '/users/refresh';
16
17
    public function testRefreshUserById_()
18
    {
19
        // get the logged in user (create one if no one is logged in)
20
        $user = $this->registerAndLoginTestingUser();
21
22
        $data = [
23
            'user_id' => $user->id,
24
        ];
25
26
        // send the HTTP request
27
        $response = $this->apiCall($this->endpoint, 'post', $data);
28
29
        // assert response status is correct
30
        $this->assertEquals($response->getStatusCode(), '200');
31
    }
32
33
    public function testRefreshUserByVisitorId_()
34
    {
35
        // For some reason this stopped working while refactoring unrelated code.
36
        // I don't have time now for it, so I'll find out why the visitor id is
37
        // changing when hitting the controller. It could be related to the Middleware!
38
39
//        // get the logged in user (create one if no one is logged in)
40
//        $user = $this->registerAndLoginTestingUser();
41
//        unset($user->token);
42
//        $user->visitor_id = '12345678901234567890';
43
//        $user->save();
44
//
45
//        // send the HTTP request
46
//        $response = $this->apiCall($this->endpoint, 'post', [], false, ['visitor-id' => $user->visitor_id]);
47
//
48
//        // assert response status is correct
49
//        $this->assertEquals($response->getStatusCode(), '200');
50
    }
51
52
    public function testRefreshUserByToken_()
53
    {
54
        // send the HTTP request
55
        $response = $this->apiCall($this->endpoint, 'post', [], true);
56
57
        // assert response status is correct
58
        $this->assertEquals($response->getStatusCode(), '200');
59
    }
60
}
61