@@ -56,6 +56,10 @@ public static function dataValidNotClassFormatPublic()
56
56
'name ' => 'thisISCamelCaps ' ,
57
57
'strict ' => false ,
58
58
],
59
+ 'lower camelCase string with initial acronym ' => [
60
+ 'name ' => 'ISThisCamelCaps ' ,
61
+ 'strict ' => false ,
62
+ ],
59
63
];
60
64
61
65
}//end dataValidNotClassFormatPublic()
@@ -87,36 +91,49 @@ public function testInvalidNotClassFormatPublic($name)
87
91
public static function dataInvalidNotClassFormatPublic ()
88
92
{
89
93
return [
90
- 'string with initial underscore (invalid when $public is true) ' => [
94
+ 'string with initial underscore (invalid when $public is true) ' => [
91
95
'name ' => '_thisIsCamelCaps ' ,
92
96
],
93
- 'lower camelCase string with acronym (invalid when $strict is true) ' => [
97
+ 'lower camelCase string with acronym (invalid when $strict is true) ' => [
94
98
'name ' => 'thisISCamelCaps ' ,
95
99
],
96
- 'PascalCase string ' => [
100
+ 'lower camelCase string with initial acronym (invalid when $strict is true) ' => [
101
+ 'name ' => 'ISThisCamelCaps ' ,
102
+ ],
103
+ 'PascalCase string ' => [
97
104
'name ' => 'ThisIsCamelCaps ' ,
98
105
],
99
- 'lower camelCase string with initial digit ' => [
106
+ 'lower camelCase string with initial digit ' => [
100
107
'name ' => '3thisIsCamelCaps ' ,
101
108
],
102
- 'lower camelCase string with initial [^a-zA-z_] character: * ' => [
109
+ 'lower camelCase string with initial illegal character: * ' => [
103
110
'name ' => '*thisIsCamelCaps ' ,
104
111
],
105
- 'lower camelCase string with initial [^a-zA-z_] character: - ' => [
112
+ 'lower camelCase string with initial illegal character: - ' => [
106
113
'name ' => '-thisIsCamelCaps ' ,
107
114
],
108
- 'lower camelCase string with medial [^a-zA-z_] character: * ' => [
115
+ 'lower camelCase string with initial illegal character: é ' => [
116
+ 'name ' => 'éCamelCaps ' ,
117
+ ],
118
+ 'lower camelCase string with medial illegal character: * ' => [
109
119
'name ' => 'this*IsCamelCaps ' ,
110
120
],
111
- 'lower camelCase string with medial [^a-zA-z_] character: - ' => [
121
+ 'lower camelCase string with medial illegal character: - ' => [
112
122
'name ' => 'this-IsCamelCaps ' ,
113
123
],
114
- 'lower camelCase string with single medial underscore ' => [
124
+ 'lower camelCase string with medial illegal character: é ' => [
125
+ // No camels were harmed in the cspell:disable-next-line.
126
+ 'name ' => 'thisIsCamélCaps ' ,
127
+ ],
128
+ 'lower camelCase string with single medial underscore ' => [
115
129
'name ' => 'this_IsCamelCaps ' ,
116
130
],
117
- 'snake_case string ' => [
131
+ 'snake_case string ' => [
118
132
'name ' => 'this_is_camel_caps ' ,
119
133
],
134
+ 'empty string ' => [
135
+ 'name ' => '' ,
136
+ ],
120
137
];
121
138
122
139
}//end dataInvalidNotClassFormatPublic()
@@ -149,19 +166,23 @@ public function testValidNotClassFormatPrivate($name, $strict)
149
166
public static function dataValidNotClassFormatPrivate ()
150
167
{
151
168
return [
152
- 'lower camelCase string with initial underscore ' => [
169
+ 'lower camelCase string with initial underscore ' => [
153
170
'name ' => '_thisIsCamelCaps ' ,
154
171
'strict ' => true ,
155
172
],
156
- 'lower camelCase string with acronym and initial underscore ' => [
173
+ 'lower camelCase string with acronym and initial underscore ' => [
157
174
'name ' => '_thisISCamelCaps ' ,
158
175
'strict ' => false ,
159
176
],
160
- '_i18N ' => [
177
+ 'lower camelCase string with acronym after initial underscore ' => [
178
+ 'name ' => '_ISThisCamelCaps ' ,
179
+ 'strict ' => false ,
180
+ ],
181
+ 'numeronym with initial underscore and capital after digit ' => [
161
182
'name ' => '_i18N ' ,
162
183
'strict ' => true ,
163
184
],
164
- '_i18n ' => [
185
+ 'numeronym with initial underscore and lowercase character after digit ' => [
165
186
'name ' => '_i18n ' ,
166
187
'strict ' => true ,
167
188
],
@@ -221,18 +242,30 @@ public static function dataInvalidNotClassFormatPrivate()
221
242
'name ' => '3thisIsCamelCaps ' ,
222
243
'strict ' => true ,
223
244
],
224
- 'lower camelCase string with initial [^a-zA-Z_] character: * ' => [
245
+ 'lower camelCase string with initial illegal character: * ' => [
225
246
'name ' => '*thisIsCamelCaps ' ,
226
247
'strict ' => true ,
227
248
],
228
- 'lower camelCase string with initial [^a-zA-Z_] character: - ' => [
249
+ 'lower camelCase string with initial illegal character: - ' => [
229
250
'name ' => '-thisIsCamelCaps ' ,
230
251
'strict ' => true ,
231
252
],
253
+ 'lower camelCase string with initial illegal character: é ' => [
254
+ 'name ' => 'éCamelCaps ' ,
255
+ 'strict ' => true ,
256
+ ],
232
257
'snake_case string with initial underscore ' => [
233
258
'name ' => '_this_is_camel_caps ' ,
234
259
'strict ' => true ,
235
260
],
261
+ 'single underscore ' => [
262
+ 'name ' => '_ ' ,
263
+ 'strict ' => true ,
264
+ ],
265
+ 'empty string ' => [
266
+ 'name ' => '' ,
267
+ 'strict ' => true ,
268
+ ],
236
269
];
237
270
238
271
}//end dataInvalidNotClassFormatPrivate()
@@ -277,6 +310,26 @@ public static function dataValidClassFormatPublic()
277
310
'name ' => 'This3IsCamelCaps ' ,
278
311
'strict ' => false ,
279
312
],
313
+ 'PascalCase string with digit inside word ' => [
314
+ 'name ' => 'Th1sIsCamelCaps ' ,
315
+ 'strict ' => false ,
316
+ ],
317
+ 'Single capital (strict) ' => [
318
+ 'name ' => 'A ' ,
319
+ 'strict ' => true ,
320
+ ],
321
+ 'Single capital with digit (strict) ' => [
322
+ 'name ' => 'A1 ' ,
323
+ 'strict ' => true ,
324
+ ],
325
+ 'Single capital (relaxed) ' => [
326
+ 'name ' => 'A ' ,
327
+ 'strict ' => false ,
328
+ ],
329
+ 'Single capital with digit (relaxed) ' => [
330
+ 'name ' => 'A1 ' ,
331
+ 'strict ' => false ,
332
+ ],
280
333
];
281
334
282
335
}//end dataValidClassFormatPublic()
@@ -317,6 +370,9 @@ public static function dataInvalidClassFormat()
317
370
'capitalised snake case ' => [
318
371
'name ' => 'This_Is_Camel_Caps ' ,
319
372
],
373
+ 'empty string ' => [
374
+ 'name ' => '' ,
375
+ ],
320
376
];
321
377
322
378
}//end dataInvalidClassFormat()
@@ -360,9 +416,97 @@ public static function dataInvalidClassFormatPrivate()
360
416
'name ' => '_ThisIsCamelCaps ' ,
361
417
'public ' => false ,
362
418
],
419
+ 'empty string (public) ' => [
420
+ 'name ' => '' ,
421
+ 'public ' => true ,
422
+ ],
423
+ 'empty string (private) ' => [
424
+ 'name ' => '' ,
425
+ 'public ' => false ,
426
+ ],
363
427
];
364
428
365
429
}//end dataInvalidClassFormatPrivate()
366
430
367
431
432
+ /**
433
+ * Test valid strings with default arguments.
434
+ *
435
+ * @param string $name The tested name.
436
+ *
437
+ * @dataProvider dataValidDefaultArguments
438
+ *
439
+ * @return void
440
+ */
441
+ public function testValidDefaultArguments ($ name )
442
+ {
443
+ $ this ->assertTrue (Common::isCamelCaps ($ name ));
444
+
445
+ }//end testValidDefaultArguments()
446
+
447
+
448
+ /**
449
+ * Data provider.
450
+ *
451
+ * @see testValidDefaultArguments()
452
+ *
453
+ * @return array<string, array<string, string>>
454
+ */
455
+ public static function dataValidDefaultArguments ()
456
+ {
457
+ return [
458
+ 'lower camelCase string ' => [
459
+ 'name ' => 'thisIsCamelCaps ' ,
460
+ ],
461
+ 'lower camelCase string with medial digit ' => [
462
+ 'name ' => 'this3IsCamelCaps ' ,
463
+ ],
464
+ ];
465
+
466
+ }//end dataValidDefaultArguments()
467
+
468
+
469
+ /**
470
+ * Test invalid strings with default arguments.
471
+ *
472
+ * @param string $name The tested name.
473
+ *
474
+ * @dataProvider dataInvalidDefaultArguments
475
+ *
476
+ * @return void
477
+ */
478
+ public function testInvalidDefaultArguments ($ name )
479
+ {
480
+ $ this ->assertFalse (Common::isCamelCaps ($ name ));
481
+
482
+ }//end testInvalidDefaultArguments()
483
+
484
+
485
+ /**
486
+ * Data provider.
487
+ *
488
+ * @see testInvalidDefaultArguments()
489
+ *
490
+ * @return array<string, array<string, string>>
491
+ */
492
+ public static function dataInvalidDefaultArguments ()
493
+ {
494
+ return [
495
+ 'PascalCase string ' => [
496
+ 'name ' => 'ThisIsCamelCaps ' ,
497
+ ],
498
+ 'PascalCase string with acronym ' => [
499
+ 'name ' => 'ThisISCamelCaps ' ,
500
+ ],
501
+ 'lower camelCase string with initial underscore ' => [
502
+ 'name ' => '_thisIsCamelCaps ' ,
503
+ ],
504
+ 'lower camelCase string with acronym ' => [
505
+ 'name ' => 'thisISCamelCaps ' ,
506
+ ],
507
+ ];
508
+
509
+ }//end dataInvalidDefaultArguments()
510
+
511
+
368
512
}//end class
0 commit comments