Code Duplication    Length = 17-20 lines in 5 locations

app/Containers/User/UI/API/Tests/Functional/RegisterUserTest.php 4 locations

@@ 113-130 (lines=18) @@
110
    /**
111
     * @test
112
     */
113
    public function testRegisterNewUserWithoutEmail()
114
    {
115
        $data = [
116
            'name'     => 'Apiato',
117
            'password' => 'secret',
118
        ];
119
120
        // send the HTTP request
121
        $response = $this->makeCall($data);
122
123
        // assert response status is correct
124
        $response->assertStatus(422);
125
126
        // assert response contain the correct message
127
        $this->assertValidationErrorContain([
128
            'email' => 'The email field is required.',
129
        ]);
130
    }
131
132
    /**
133
     * @test
@@ 135-152 (lines=18) @@
132
    /**
133
     * @test
134
     */
135
    public function testRegisterNewUserWithoutName()
136
    {
137
        $data = [
138
            'email'    => '[email protected]',
139
            'password' => 'secret',
140
        ];
141
142
        // send the HTTP request
143
        $response = $this->makeCall($data);
144
145
        // assert response status is correct
146
        $response->assertStatus(422);
147
148
        // assert response contain the correct message
149
        $this->assertValidationErrorContain([
150
            'name' => 'The name field is required.',
151
        ]);
152
    }
153
154
    /**
155
     * @test
@@ 157-173 (lines=17) @@
154
    /**
155
     * @test
156
     */
157
    public function testRegisterNewUserWithoutPassword()
158
    {
159
        $data = [
160
            'email' => '[email protected]',
161
            'name'  => 'Apiato',
162
        ];
163
164
        $response = $this->makeCall($data);
165
166
        // assert response status is correct
167
        $response->assertStatus(422);
168
169
        // assert response contain the correct message
170
        $this->assertValidationErrorContain([
171
            'password' => 'The password field is required.',
172
        ]);
173
    }
174
175
    /**
176
     * @test
@@ 178-196 (lines=19) @@
175
    /**
176
     * @test
177
     */
178
    public function testRegisterNewUserWithInvalidEmail()
179
    {
180
        $data = [
181
            'email'    => 'missing-at.test',
182
            'name'     => 'Apiato',
183
            'password' => 'secret',
184
        ];
185
186
        // send the HTTP request
187
        $response = $this->makeCall($data);
188
189
        // assert response status is correct
190
        $response->assertStatus(422);
191
192
        // assert response contain the correct message
193
        $this->assertValidationErrorContain([
194
            'email' => 'The email must be a valid email address.',
195
        ]);
196
    }
197
}
198

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

@@ 95-114 (lines=20) @@
92
    /**
93
     * @test
94
     */
95
    public function testUpdateExistingUserWithEmptyValues()
96
    {
97
        $data = [
98
            'name'     => '',
99
            'password' => '',
100
        ];
101
102
        // send the HTTP request
103
        $response = $this->makeCall($data);
104
105
        // assert response status is correct
106
        $response->assertStatus(422);
107
108
        $this->assertValidationErrorContain([
109
            // messages should be updated after modifying the validation rules, to pass this test
110
            'password' => 'The password must be at least 6 characters.',
111
            'name'     => 'The name must be at least 2 characters.',
112
        ]);
113
114
    }
115
}
116