@@ -322,8 +322,9 @@ public function validTypedArrayDataProvider(): array
322322 * @dataProvider invalidTypedArrayDataProvider
323323 *
324324 * @param GeneratorConfiguration $configuration
325- * @param string $type
326- * @param $propertyValue
325+ * @param string $type
326+ * @param $propertyValue
327+ * @param string $message
327328 *
328329 * @throws FileSystemException
329330 * @throws RenderException
@@ -332,9 +333,10 @@ public function validTypedArrayDataProvider(): array
332333 public function testInvalidTypedArrayThrowsAnException (
333334 GeneratorConfiguration $ configuration ,
334335 string $ type ,
335- $ propertyValue
336+ $ propertyValue ,
337+ string $ message = ''
336338 ): void {
337- $ this ->expectValidationError ($ configuration , ' Invalid type for item of array ' );
339+ $ this ->expectValidationError ($ configuration , $ message );
338340
339341 $ className = $ this ->generateClassFromFileTemplate ('ArrayPropertyTyped.json ' , [$ type ], $ configuration , false );
340342
@@ -346,19 +348,90 @@ public function invalidTypedArrayDataProvider(): array
346348 return $ this ->combineDataProvider (
347349 $ this ->validationMethodDataProvider (),
348350 [
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+ ],
355416 'Nested array containing int ' => [
356417 '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
358424 ],
359425 'Nested array inner array containing string ' => [
360426 '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
362435 ]
363436 ]
364437 );
0 commit comments