@@ -73,192 +73,100 @@ public function testValidate($expectedResult, array $methods): void
73
73
74
74
public function provideValidateApiUserData (): Generator
75
75
{
76
+ $ validUser = [
77
+ 'getUsername ' => 'validuser ' ,
78
+ 'getFirstname ' => 'John ' ,
79
+ 'getLastname ' => 'Doe ' ,
80
+ 'getEmail ' =>
'[email protected] ' ,
81
+ 'hasNewApiKey ' => false ,
82
+ 'getNewApiKey ' => null ,
83
+ 'hasApiKey ' => true ,
84
+ 'getApiKey ' => 'validapikey123 ' ,
85
+ 'hasApiKeyConfirmation ' => true ,
86
+ 'getApiKeyConfirmation ' => 'validapikey123 ' ,
87
+ 'userExists ' => false ,
88
+ ];
89
+
76
90
yield 'valid data ' => [
77
91
true ,
78
- [
79
- 'getUsername ' => 'validuser ' ,
80
- 'getFirstname ' => 'John ' ,
81
- 'getLastname ' => 'Doe ' ,
82
- 'getEmail ' =>
'[email protected] ' ,
83
- 'hasNewApiKey ' => false ,
84
- 'getNewApiKey ' => null ,
85
- 'hasApiKey ' => true ,
86
- 'getApiKey ' => 'validapikey123 ' ,
87
- 'hasApiKeyConfirmation ' => true ,
88
- 'getApiKeyConfirmation ' => 'validapikey123 ' ,
89
- 'userExists ' => false ,
90
- ],
92
+ $ validUser ,
91
93
];
94
+
95
+ $ data = $ validUser ;
96
+ $ data ['getUsername ' ] = '' ;
92
97
yield 'missing username ' => [
93
98
['User Name is required field. ' ],
94
- [
95
- 'getUsername ' => '' ,
96
- 'getFirstname ' => 'John ' ,
97
- 'getLastname ' => 'Doe ' ,
98
- 'getEmail ' =>
'[email protected] ' ,
99
- 'hasNewApiKey ' => false ,
100
- 'getNewApiKey ' => null ,
101
- 'hasApiKey ' => true ,
102
- 'getApiKey ' => 'validapikey123 ' ,
103
- 'hasApiKeyConfirmation ' => true ,
104
- 'getApiKeyConfirmation ' => 'validapikey123 ' ,
105
- 'userExists ' => false ,
106
- ],
99
+ $ data ,
107
100
];
101
+
102
+ $ data = $ validUser ;
103
+ $ data ['getFirstname ' ] = '' ;
108
104
yield 'missing firstname ' => [
109
105
['First Name is required field. ' ],
110
- [
111
- 'getUsername ' => 'jd ' ,
112
- 'getFirstname ' => '' ,
113
- 'getLastname ' => 'Doe ' ,
114
- 'getEmail ' =>
'[email protected] ' ,
115
- 'hasNewApiKey ' => false ,
116
- 'getNewApiKey ' => null ,
117
- 'hasApiKey ' => true ,
118
- 'getApiKey ' => 'validapikey123 ' ,
119
- 'hasApiKeyConfirmation ' => true ,
120
- 'getApiKeyConfirmation ' => 'validapikey123 ' ,
121
- 'userExists ' => false ,
122
- ],
106
+ $ data ,
123
107
];
108
+
109
+ $ data = $ validUser ;
110
+ $ data ['getLastname ' ] = '' ;
124
111
yield 'missing lastname ' => [
125
112
['Last Name is required field. ' ],
126
- [
127
- 'getUsername ' => 'jd ' ,
128
- 'getFirstname ' => 'John ' ,
129
- 'getLastname ' => '' ,
130
- 'getEmail ' =>
'[email protected] ' ,
131
- 'hasNewApiKey ' => false ,
132
- 'getNewApiKey ' => null ,
133
- 'hasApiKey ' => true ,
134
- 'getApiKey ' => 'validapikey123 ' ,
135
- 'hasApiKeyConfirmation ' => true ,
136
- 'getApiKeyConfirmation ' => 'validapikey123 ' ,
137
- 'userExists ' => false ,
138
- ],
113
+ $ data ,
139
114
];
115
+
116
+ $ data = $ validUser ;
117
+ $ data ['getEmail ' ] = '' ;
140
118
yield 'missing email ' => [
141
119
['Please enter a valid email. ' ],
142
- [
143
- 'getUsername ' => 'jd ' ,
144
- 'getFirstname ' => 'John ' ,
145
- 'getLastname ' => 'Doe ' ,
146
- 'getEmail ' => '' ,
147
- 'hasNewApiKey ' => false ,
148
- 'getNewApiKey ' => null ,
149
- 'hasApiKey ' => true ,
150
- 'getApiKey ' => 'validapikey123 ' ,
151
- 'hasApiKeyConfirmation ' => true ,
152
- 'getApiKeyConfirmation ' => 'validapikey123 ' ,
153
- 'userExists ' => false ,
154
- ],
120
+ $ data ,
155
121
];
122
+
123
+ $ data = $ validUser ;
124
+ $ data ['getEmail ' ] = 'invalid-email ' ;
156
125
yield 'invalid email ' => [
157
126
['Please enter a valid email. ' ],
158
- [
159
- 'getUsername ' => 'jd ' ,
160
- 'getFirstname ' => 'John ' ,
161
- 'getLastname ' => 'Doe ' ,
162
- 'getEmail ' => 'invalidemail ' ,
163
- 'hasNewApiKey ' => false ,
164
- 'getNewApiKey ' => null ,
165
- 'hasApiKey ' => true ,
166
- 'getApiKey ' => 'validapikey123 ' ,
167
- 'hasApiKeyConfirmation ' => true ,
168
- 'getApiKeyConfirmation ' => 'validapikey123 ' ,
169
- 'userExists ' => false ,
170
- ],
127
+ $ data ,
171
128
];
129
+
130
+ $ data = $ validUser ;
131
+ $ data ['getApiKey ' ] = '' ;
172
132
yield 'missing api key ' => [
173
133
[
174
134
'Api Key must be at least of 7 characters. ' ,
175
135
'Api Key confirmation must be same as Api Key. ' ,
176
136
],
177
- [
178
- 'getUsername ' => 'jd ' ,
179
- 'getFirstname ' => 'John ' ,
180
- 'getLastname ' => 'Doe ' ,
181
- 'getEmail ' =>
'[email protected] ' ,
182
- 'hasNewApiKey ' => false ,
183
- 'getNewApiKey ' => null ,
184
- 'hasApiKey ' => true ,
185
- 'getApiKey ' => '' ,
186
- 'hasApiKeyConfirmation ' => true ,
187
- 'getApiKeyConfirmation ' => 'validapikey123 ' ,
188
- 'userExists ' => false ,
189
- ],
137
+ $ data ,
190
138
];
139
+
140
+ $ data = $ validUser ;
141
+ $ data ['getApiKeyConfirmation ' ] = '' ;
191
142
yield 'missing api confirm key ' => [
192
- [
193
- 'Api Key confirmation must be same as Api Key. ' ,
194
- ],
195
- [
196
- 'getUsername ' => 'jd ' ,
197
- 'getFirstname ' => 'John ' ,
198
- 'getLastname ' => 'Doe ' ,
199
- 'getEmail ' =>
'[email protected] ' ,
200
- 'hasNewApiKey ' => false ,
201
- 'getNewApiKey ' => null ,
202
- 'hasApiKey ' => true ,
203
- 'getApiKey ' => 'validapikey123 ' ,
204
- 'hasApiKeyConfirmation ' => true ,
205
- 'getApiKeyConfirmation ' => '' ,
206
- 'userExists ' => false ,
207
- ],
143
+ ['Api Key confirmation must be same as Api Key. ' ],
144
+ $ data ,
208
145
];
146
+
147
+ $ data = $ validUser ;
148
+ $ apiKey = '1234567 ' ;
149
+ $ data ['getApiKey ' ] = $ apiKey ;
150
+ $ data ['getApiKeyConfirmation ' ] = $ apiKey ;
209
151
yield 'numeric only api key ' => [
210
- [
211
- 'Api Key must include both numeric and alphabetic characters. ' ,
212
- ],
213
- [
214
- 'getUsername ' => 'jd ' ,
215
- 'getFirstname ' => 'John ' ,
216
- 'getLastname ' => 'Doe ' ,
217
- 'getEmail ' =>
'[email protected] ' ,
218
- 'hasNewApiKey ' => false ,
219
- 'getNewApiKey ' => null ,
220
- 'hasApiKey ' => true ,
221
- 'getApiKey ' => '1234567 ' ,
222
- 'hasApiKeyConfirmation ' => true ,
223
- 'getApiKeyConfirmation ' => '1234567 ' ,
224
- 'userExists ' => false ,
225
- ],
152
+ ['Api Key must include both numeric and alphabetic characters. ' ],
153
+ $ data ,
226
154
];
155
+
156
+ $ data = $ validUser ;
157
+ $ apiKey = 'abcdefg ' ;
158
+ $ data ['getApiKey ' ] = $ apiKey ;
159
+ $ data ['getApiKeyConfirmation ' ] = $ apiKey ;
227
160
yield 'string only api key ' => [
228
- [
229
- 'Api Key must include both numeric and alphabetic characters. ' ,
230
- ],
231
- [
232
- 'getUsername ' => 'jd ' ,
233
- 'getFirstname ' => 'John ' ,
234
- 'getLastname ' => 'Doe ' ,
235
- 'getEmail ' =>
'[email protected] ' ,
236
- 'hasNewApiKey ' => false ,
237
- 'getNewApiKey ' => null ,
238
- 'hasApiKey ' => true ,
239
- 'getApiKey ' => 'abcdefg ' ,
240
- 'hasApiKeyConfirmation ' => true ,
241
- 'getApiKeyConfirmation ' => 'abcdefg ' ,
242
- 'userExists ' => false ,
243
- ],
161
+ ['Api Key must include both numeric and alphabetic characters. ' ],
162
+ $ data ,
244
163
];
164
+
165
+ $ data = $ validUser ;
166
+ $ data ['userExists ' ] = true ;
245
167
yield 'user exists ' => [
246
- [
247
- 'A user with the same user name or email already exists. ' ,
248
- ],
249
- [
250
- 'getUsername ' => 'jd ' ,
251
- 'getFirstname ' => 'John ' ,
252
- 'getLastname ' => 'Doe ' ,
253
- 'getEmail ' =>
'[email protected] ' ,
254
- 'hasNewApiKey ' => false ,
255
- 'getNewApiKey ' => null ,
256
- 'hasApiKey ' => true ,
257
- 'getApiKey ' => 'validapikey123 ' ,
258
- 'hasApiKeyConfirmation ' => true ,
259
- 'getApiKeyConfirmation ' => 'validapikey123 ' ,
260
- 'userExists ' => true ,
261
- ],
168
+ ['A user with the same user name or email already exists. ' ],
169
+ $ data ,
262
170
];
263
171
}
264
172
}
0 commit comments