Code Duplication    Length = 16-19 lines in 8 locations

app/Containers/User/UI/API/Tests/Functional/LoginTest.php 2 locations

@@ 49-66 (lines=18) @@
46
        $this->assertResponseContainKeys(['id', 'token'], $response);
47
    }
48
49
    public function testLoginExistingUserUsingGetRequest()
50
    {
51
        $data = [
52
            'email'    => '[email protected]',
53
            'password' => 'secret',
54
        ];
55
56
        // send the HTTP request
57
        $response = $this->apiCall($this->endpoint, 'get', $data, false);
58
59
        // assert response status is correct
60
        $this->assertEquals($response->getStatusCode(), '405');
61
62
        // assert message is correct
63
        $this->assertResponseContainKeyValue([
64
            'message' => '405 Method Not Allowed',
65
        ], $response);
66
    }
67
68
    public function testLoginNonExistingUser()
69
    {
@@ 68-85 (lines=18) @@
65
        ], $response);
66
    }
67
68
    public function testLoginNonExistingUser()
69
    {
70
        $data = [
71
            'email'    => '[email protected]',
72
            'password' => 'secret',
73
        ];
74
75
        // send the HTTP request
76
        $response = $this->apiCall($this->endpoint, 'post', $data, false);
77
78
        // assert response status is correct
79
        $this->assertEquals($response->getStatusCode(), '401');
80
81
        // assert message is correct
82
        $this->assertResponseContainKeyValue([
83
            'message' => 'Credentials Incorrect.',
84
        ], $response);
85
    }
86
87
    public function testLoginExistingUserWithoutEmail_()
88
    {

app/Containers/User/UI/API/Tests/Functional/RegisterTest.php 5 locations

@@ 43-61 (lines=19) @@
40
        $this->seeInDatabase('users', ['email' => $data['email']]);
41
    }
42
43
    public function testRegisterNewUserUsingGetVerb()
44
    {
45
        $data = [
46
            'email'    => '[email protected]',
47
            'name'     => 'Hello',
48
            'password' => 'secret',
49
        ];
50
51
        // send the HTTP request
52
        $response = $this->apiCall($this->endpoint, 'get', $data, false);
53
54
        // assert response status is correct
55
        $this->assertEquals($response->getStatusCode(), '405');
56
57
        // assert response contain the correct message
58
        $this->assertResponseContainKeyValue([
59
            'message' => '405 Method Not Allowed',
60
        ], $response);
61
    }
62
63
    public function testRegisterExistingUser()
64
    {
@@ 92-109 (lines=18) @@
89
        ], $response);
90
    }
91
92
    public function testRegisterNewUserWithoutEmail()
93
    {
94
        $data = [
95
            'name'     => 'Hello',
96
            'password' => 'secret',
97
        ];
98
99
        // send the HTTP request
100
        $response = $this->apiCall($this->endpoint, 'post', $data, false);
101
102
        // assert response status is correct
103
        $this->assertEquals($response->getStatusCode(), '422');
104
105
        // assert response contain the correct message
106
        $this->assertValidationErrorContain($response, [
107
            'email' => 'The email field is required.',
108
        ]);
109
    }
110
111
    public function testRegisterNewUserWithoutName()
112
    {
@@ 111-128 (lines=18) @@
108
        ]);
109
    }
110
111
    public function testRegisterNewUserWithoutName()
112
    {
113
        $data = [
114
            'email'    => '[email protected]',
115
            'password' => 'secret',
116
        ];
117
118
        // send the HTTP request
119
        $response = $this->apiCall($this->endpoint, 'post', $data, false);
120
121
        // assert response status is correct
122
        $this->assertEquals($response->getStatusCode(), '422');
123
124
        // assert response contain the correct message
125
        $this->assertValidationErrorContain($response, [
126
            'name' => 'The name field is required.',
127
        ]);
128
    }
129
130
    public function testRegisterNewUserWithoutPassword()
131
    {
@@ 130-146 (lines=17) @@
127
        ]);
128
    }
129
130
    public function testRegisterNewUserWithoutPassword()
131
    {
132
        $data = [
133
            'email' => '[email protected]',
134
            'name'  => 'Hello',
135
        ];
136
137
        $response = $this->apiCall($this->endpoint, 'post', $data, false);
138
139
        // assert response status is correct
140
        $this->assertEquals($response->getStatusCode(), '422');
141
142
        // assert response contain the correct message
143
        $this->assertValidationErrorContain($response, [
144
            'password' => 'The password field is required.',
145
        ]);
146
    }
147
148
    public function testRegisterNewUserWithInvalidEmail()
149
    {
@@ 148-166 (lines=19) @@
145
        ]);
146
    }
147
148
    public function testRegisterNewUserWithInvalidEmail()
149
    {
150
        $data = [
151
            'email'    => 'missing-at.dev',
152
            'name'     => 'Hello',
153
            'password' => 'secret',
154
        ];
155
156
        // send the HTTP request
157
        $response = $this->apiCall($this->endpoint, 'post', $data, false);
158
159
        // assert response status is correct
160
        $this->assertEquals($response->getStatusCode(), '422');
161
162
        // assert response contain the correct message
163
        $this->assertValidationErrorContain($response, [
164
            'email' => 'The email must be a valid email address.',
165
        ]);
166
    }
167
}
168

app/Containers/Email/UI/API/Tests/Functional/SetVisitorEmailTest.php 1 location

@@ 18-33 (lines=16) @@
15
16
    private $endpoint = '/visitors/email';
17
18
    public function testSetVisitorEmail_()
19
    {
20
        $data = [
21
            'email' => '[email protected]',
22
        ];
23
24
        // send the HTTP request
25
        $response = $this->apiCall($this->endpoint, 'post', $data, false);
26
27
        // assert response status is correct
28
        $this->assertEquals($response->getStatusCode(), '202');
29
30
        $this->assertResponseContainKeyValue(['message' => 'Visitor Email Saved Successfully.'], $response);
31
32
        $this->seeInDatabase('users', ['email' => $data['email']]);
33
    }
34
35
}
36