@@ -322,8 +322,9 @@ public function validTypedArrayDataProvider(): array
322
322
* @dataProvider invalidTypedArrayDataProvider
323
323
*
324
324
* @param GeneratorConfiguration $configuration
325
- * @param string $type
326
- * @param $propertyValue
325
+ * @param string $type
326
+ * @param $propertyValue
327
+ * @param string $message
327
328
*
328
329
* @throws FileSystemException
329
330
* @throws RenderException
@@ -332,9 +333,10 @@ public function validTypedArrayDataProvider(): array
332
333
public function testInvalidTypedArrayThrowsAnException (
333
334
GeneratorConfiguration $ configuration ,
334
335
string $ type ,
335
- $ propertyValue
336
+ $ propertyValue ,
337
+ string $ message = ''
336
338
): void {
337
- $ this ->expectValidationError ($ configuration , ' Invalid type for item of array ' );
339
+ $ this ->expectValidationError ($ configuration , $ message );
338
340
339
341
$ className = $ this ->generateClassFromFileTemplate ('ArrayPropertyTyped.json ' , [$ type ], $ configuration , false );
340
342
@@ -346,19 +348,90 @@ public function invalidTypedArrayDataProvider(): array
346
348
return $ this ->combineDataProvider (
347
349
$ this ->validationMethodDataProvider (),
348
350
[
349
- 'String array containing int ' => ['string ' , ['a ' , 'b ' , 1 ]],
350
- 'Int array containing string ' => ['integer ' , [1 , 2 , 3 , '4 ' ]],
351
- 'Int array containing float ' => ['integer ' , [1 , 2 , 3 , 2.5 ]],
352
- 'Number array containing array ' => ['number ' , [1 , 1.1 , 4.5 , 6 , []]],
353
- 'Boolean array containing int ' => ['boolean ' , [true , false , true , 3 ]],
354
- 'Null array containing string ' => ['null ' , [null , null , 'null ' ]],
351
+ 'String array containing int ' => [
352
+ 'string ' ,
353
+ ['a ' , 'b ' , 1 ],
354
+ <<<ERROR
355
+ Invalid item in array property:
356
+ - invalid item #2
357
+ * Invalid type for item of array property. Requires string, got integer
358
+ ERROR
359
+ ],
360
+ 'Int array containing string ' => [
361
+ 'integer ' ,
362
+ [1 , 2 , 3 , '4 ' ],
363
+ <<<ERROR
364
+ Invalid item in array property:
365
+ - invalid item #3
366
+ * Invalid type for item of array property. Requires int, got string
367
+ ERROR
368
+ ],
369
+ 'Int array containing float ' => [
370
+ 'integer ' ,
371
+ [1 , 2 , 3 , 2.5 ],
372
+ <<<ERROR
373
+ Invalid item in array property:
374
+ - invalid item #3
375
+ * Invalid type for item of array property. Requires int, got double
376
+ ERROR
377
+ ],
378
+ 'Number array containing array ' => [
379
+ 'number ' ,
380
+ [1 , 1.1 , 4.5 , 6 , []],
381
+ <<<ERROR
382
+ Invalid item in array property:
383
+ - invalid item #4
384
+ * Invalid type for item of array property. Requires float, got array
385
+ ERROR
386
+ ],
387
+ 'Boolean array containing int ' => [
388
+ 'boolean ' ,
389
+ [true , false , true , 3 ],
390
+ <<<ERROR
391
+ Invalid item in array property:
392
+ - invalid item #3
393
+ * Invalid type for item of array property. Requires bool, got integer
394
+ ERROR
395
+ ],
396
+ 'Null array containing string ' => [
397
+ 'null ' ,
398
+ [null , null , 'null ' ],
399
+ <<<ERROR
400
+ Invalid item in array property:
401
+ - invalid item #2
402
+ * Invalid type for item of array property. Requires null, got string
403
+ ERROR
404
+ ],
405
+ 'Multiple violations ' => [
406
+ 'boolean ' ,
407
+ [true , false , true , 3 , true , 'true ' ],
408
+ <<<ERROR
409
+ Invalid item in array property:
410
+ - invalid item #3
411
+ * Invalid type for item of array property. Requires bool, got integer
412
+ - invalid item #5
413
+ * Invalid type for item of array property. Requires bool, got string
414
+ ERROR
415
+ ],
355
416
'Nested array containing int ' => [
356
417
'array","items":{"type":"integer"},"injection":"yes we can ' ,
357
- [[1 , 2 ], [], 3 ]
418
+ [[1 , 2 ], [], 3 ],
419
+ <<<ERROR
420
+ Invalid item in array property:
421
+ - invalid item #2
422
+ * Invalid type for item of array property. Requires array, got integer
423
+ ERROR
358
424
],
359
425
'Nested array inner array containing string ' => [
360
426
'array","items":{"type":"integer"},"injection":"yes we can ' ,
361
- [[1 , '2 ' ], [], [3 ]]
427
+ [[1 , '2 ' ], [], [3 ]],
428
+ <<<ERROR
429
+ Invalid item in array property:
430
+ - invalid item #0
431
+ * Invalid item in array item of array property:
432
+ - invalid item #1
433
+ * Invalid type for item of array item of array property. Requires int, got string
434
+ ERROR
362
435
]
363
436
]
364
437
);
0 commit comments