Code Duplication    Length = 13-17 lines in 4 locations

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

@@ 42-58 (lines=17) @@
39
        $this->seeInDatabase('users', ['name' => $data['name']]);
40
    }
41
42
    public function testUpdateExistingUserWithEmptyValues()
43
    {
44
        $this->getLoggedInTestingUser();
45
46
        $data = []; // empty data
47
48
        // send the HTTP request
49
        $response = $this->apiCall($this->endpoint, 'put', $data);
50
51
        // assert response status is correct
52
        $this->assertEquals($response->getStatusCode(), '417');
53
54
        // assert message is correct
55
        $this->assertResponseContainKeyValue([
56
            'message' => 'Inputs are empty.',
57
        ], $response);
58
    }
59
}
60

app/Containers/Authentication/UI/API/Tests/Functional/UserLogoutTest.php 3 locations

@@ 17-29 (lines=13) @@
14
15
    private $endpoint = '/user/logout';
16
17
    public function testUserLogout_()
18
    {
19
        // send the HTTP request
20
        $response = $this->apiCall($this->endpoint, 'post');
21
22
        // assert response status is correct
23
        $this->assertEquals($response->getStatusCode(), '202');
24
25
        // assert message is correct
26
        $this->assertResponseContainKeyValue([
27
            'message' => 'User Logged Out Successfully.',
28
        ], $response);
29
    }
30
31
    public function testUserLogoutWithGetRequest()
32
    {
@@ 31-43 (lines=13) @@
28
        ], $response);
29
    }
30
31
    public function testUserLogoutWithGetRequest()
32
    {
33
        // send the HTTP request
34
        $response = $this->apiCall($this->endpoint, 'get');
35
36
        // assert response status is correct
37
        $this->assertEquals($response->getStatusCode(), '405');
38
39
        // assert message is correct
40
        $this->assertResponseContainKeyValue([
41
            'message' => '405 Method Not Allowed',
42
        ], $response);
43
    }
44
45
    public function testUserLogoutWithoutToken()
46
    {
@@ 45-57 (lines=13) @@
42
        ], $response);
43
    }
44
45
    public function testUserLogoutWithoutToken()
46
    {
47
        // send the HTTP request
48
        $response = $this->apiCall($this->endpoint, 'post', [], false);
49
50
        // assert response status is correct
51
        $this->assertEquals($response->getStatusCode(), '401');
52
53
        // assert message is correct
54
        $this->assertResponseContainKeyValue([
55
            'message' => 'Failed to authenticate because of bad credentials or an invalid authorization header.',
56
        ], $response);
57
    }
58
}
59