@@ -202,4 +202,124 @@ public function testDateTimeExceptionClassesExist()
202
202
$ this ->assertTrue (class_exists (\DateMalformedIntervalStringException::class));
203
203
$ this ->assertTrue (class_exists (\DateMalformedPeriodStringException::class));
204
204
}
205
+
206
+ /**
207
+ * @covers \Symfony\Polyfill\Php83\Php83::str_increment
208
+ *
209
+ * @dataProvider strIncrementProvider
210
+ */
211
+ public function testStrIncrement (string $ result , string $ string )
212
+ {
213
+ $ this ->assertSame ($ result , str_increment ($ string ));
214
+ }
215
+
216
+ /**
217
+ * @covers \Symfony\Polyfill\Php83\Php83::str_decrement
218
+ *
219
+ * @dataProvider strDecrementProvider
220
+ */
221
+ public function testStrDecrement (string $ result , string $ string )
222
+ {
223
+ $ this ->assertSame ($ result , str_decrement ($ string ));
224
+ }
225
+
226
+ public static function strIncrementProvider (): iterable
227
+ {
228
+ yield ['ABD ' , 'ABC ' ];
229
+ yield ['EB ' , 'EA ' ];
230
+ yield ['AAA ' , 'ZZ ' ];
231
+ yield ['Ba ' , 'Az ' ];
232
+ yield ['bA ' , 'aZ ' ];
233
+ yield ['B0 ' , 'A9 ' ];
234
+ yield ['b0 ' , 'a9 ' ];
235
+ yield ['AAa ' , 'Zz ' ];
236
+ yield ['aaA ' , 'zZ ' ];
237
+ yield ['10a ' , '9z ' ];
238
+ yield ['10A ' , '9Z ' ];
239
+ yield ['5e7 ' , '5e6 ' ];
240
+ yield ['e ' , 'd ' ];
241
+ yield ['E ' , 'D ' ];
242
+ yield ['5 ' , '4 ' ];
243
+ }
244
+
245
+ public static function strDecrementProvider (): iterable
246
+ {
247
+ yield ['Ay ' , 'Az ' ];
248
+ yield ['aY ' , 'aZ ' ];
249
+ yield ['A8 ' , 'A9 ' ];
250
+ yield ['a8 ' , 'a9 ' ];
251
+ yield ['Yz ' , 'Za ' ];
252
+ yield ['yZ ' , 'zA ' ];
253
+ yield ['Y9 ' , 'Z0 ' ];
254
+ yield ['y9 ' , 'z0 ' ];
255
+ yield ['Z ' , 'aA ' ];
256
+ yield ['9 ' , 'A0 ' ];
257
+ yield ['9 ' , 'a0 ' ];
258
+ yield ['9 ' , '10 ' ];
259
+ yield ['Z ' , '1A ' ];
260
+ yield ['z ' , '1a ' ];
261
+ yield ['9z ' , '10a ' ];
262
+ yield ['5e5 ' , '5e6 ' ];
263
+ yield ['C ' , 'D ' ];
264
+ yield ['c ' , 'd ' ];
265
+ yield ['3 ' , '4 ' ];
266
+ }
267
+
268
+ /**
269
+ * @covers \Symfony\Polyfill\Php83\Php83::str_increment
270
+ *
271
+ * @dataProvider strInvalidIncrementProvider
272
+ */
273
+ public function testInvalidStrIncrement (string $ errorMessage , string $ string )
274
+ {
275
+ $ this ->expectException (\ValueError::class);
276
+ $ this ->expectExceptionMessage ($ errorMessage );
277
+
278
+ str_increment ($ string );
279
+ }
280
+
281
+
282
+ public static function strInvalidIncrementProvider (): iterable
283
+ {
284
+ yield ['str_increment(): Argument #1 ($string) cannot be empty ' , "" ];
285
+ yield ['str_increment(): Argument #1 ($string) must be composed only of alphanumeric ASCII characters ' , "-cc " ];
286
+ yield ['str_increment(): Argument #1 ($string) must be composed only of alphanumeric ASCII characters ' , "Z " ];
287
+ yield ['str_increment(): Argument #1 ($string) must be composed only of alphanumeric ASCII characters ' , " Z " ];
288
+ yield ['str_increment(): Argument #1 ($string) must be composed only of alphanumeric ASCII characters ' , "é " ];
289
+ yield ['str_increment(): Argument #1 ($string) must be composed only of alphanumeric ASCII characters ' , '我喜歡雞肉 ' ];
290
+ yield ['str_increment(): Argument #1 ($string) must be composed only of alphanumeric ASCII characters ' , 'α ' ];
291
+ yield ['str_increment(): Argument #1 ($string) must be composed only of alphanumeric ASCII characters ' , 'ω ' ];
292
+ yield ['str_increment(): Argument #1 ($string) must be composed only of alphanumeric ASCII characters ' , 'Α ' ];
293
+ yield ['str_increment(): Argument #1 ($string) must be composed only of alphanumeric ASCII characters ' , 'Ω ' ];
294
+ yield ['str_increment(): Argument #1 ($string) must be composed only of alphanumeric ASCII characters ' , 'foo1.txt ' ];
295
+ yield ['str_increment(): Argument #1 ($string) must be composed only of alphanumeric ASCII characters ' , '1f.5 ' ];
296
+ yield ['str_increment(): Argument #1 ($string) must be composed only of alphanumeric ASCII characters ' , 'foo.1.txt ' ];
297
+ yield ['str_increment(): Argument #1 ($string) must be composed only of alphanumeric ASCII characters ' , '1.f.5 ' ];
298
+ }
299
+
300
+
301
+ /**
302
+ * @covers \Symfony\Polyfill\Php83\Php83::str_decrement
303
+ *
304
+ * @dataProvider strInvalidDecrementProvider
305
+ */
306
+ public function testInvalidStrDecrement (string $ errorMessage , string $ string )
307
+ {
308
+ $ this ->expectException (\ValueError::class);
309
+ $ this ->expectExceptionMessage ($ errorMessage );
310
+
311
+ str_decrement ($ string );
312
+ }
313
+
314
+ public static function strInvalidDecrementProvider (): iterable
315
+ {
316
+ yield ['str_decrement(): Argument #1 ($string) cannot be empty ' , '' ];
317
+ yield ['str_decrement(): Argument #1 ($string) must be composed only of alphanumeric ASCII characters ' , '我喜歡雞肉 ' ];
318
+ yield ['str_decrement(): Argument #1 ($string) "0" is out of decrement range ' , '0 ' ];
319
+ yield ['str_decrement(): Argument #1 ($string) "a" is out of decrement range ' , 'a ' ];
320
+ yield ['str_decrement(): Argument #1 ($string) "A" is out of decrement range ' , 'A ' ];
321
+ yield ['str_decrement(): Argument #1 ($string) "00" is out of decrement range ' , '00 ' ];
322
+ yield ['str_decrement(): Argument #1 ($string) "0a" is out of decrement range ' , '0a ' ];
323
+ yield ['str_decrement(): Argument #1 ($string) "0A" is out of decrement range ' , '0A ' ];
324
+ }
205
325
}
0 commit comments