-
-
Notifications
You must be signed in to change notification settings - Fork 86
Open
Labels
Description
ValueError: array_fill(): Argument #2 ($count) must be greater than or equal to 0
│
╵ /Users/Aerendir/Documents/path/to/app/vendor/coduo/php-matcher/src/Matcher/ArrayMatcher.php:123
╵ /Users/Aerendir/Documents/path/to/app/vendor/coduo/php-matcher/src/Matcher/ArrayMatcher.php:176
╵ /Users/Aerendir/Documents/path/to/app/vendor/coduo/php-matcher/src/Matcher/ArrayMatcher.php:176
╵ /Users/Aerendir/Documents/path/to/app/vendor/coduo/php-matcher/src/Matcher/ArrayMatcher.php:176
╵ /Users/Aerendir/Documents/path/to/app/vendor/coduo/php-matcher/src/Matcher/ArrayMatcher.php:75
╵ /Users/Aerendir/Documents/path/to/app/vendor/coduo/php-matcher/src/Matcher/ChainMatcher.php:45
╵ /Users/Aerendir/Documents/path/to/app/vendor/coduo/php-matcher/src/Matcher.php:25
╵ /Users/Aerendir/Documents/path/to/app/vendor/coduo/php-matcher/src/PHPMatcher.php:27
╵ /Users/Aerendir/Documents/path/to/app/vendor/coduo/php-matcher/src/PHPUnit/PHPMatcherConstraint.php:55
╵ /Users/Aerendir/Documents/path/to/app/vendor/coduo/php-matcher/src/PHPUnit/PHPMatcherAssertions.php:21
╵ /Users/Aerendir/Documents/path/to/app/tests/App/TestCase.php:77
╵ /Users/Aerendir/Documents/path/to/app/tests/App/MyTest.php:64
The problem is that it is not well handled the case of zero, one or more array elements to validate when using @array_previous_repeat@
.
Maybe I'm configuring wrong the pattern, but, anyway, the error should be catch and a proper error message should be shown to the developer.
What I'm trying to do is to validate an array that can contain zero, one or more elements.
With the pattern I'm using, I'm able to only validate more elements while with only one element I get the reported error. I didn't tested the pattern with zero elements.
This is the payload:
{
"@context":"\/api\/contexts\/Item",
"@id":"\/api\/accounts\/2\/items",
"@type":"hydra:Collection",
"hydra:member":[
{
"@id":"\/api\/accounts\/2\/items\/1",
"@type":"Item",
"id":1,
"account":"\/api\/accounts\/2",
"sku":"A SKU",
"title":"The title",
"shortDescription":"The short description",
"description":"The long description",
"variable":false,
"itemVariants":[
],
"images":[
{
"@id":"\/api\/accounts\/2\/items\/1\/images\/1",
"@type":"ItemImage",
"account":"\/api\/accounts\/2",
"file":{
"@id":"\/api\/accounts\/2\/files\/images\/1",
"@type":"https:\/\/schema.org\/MediaObject",
"dimensions":[
"3295",
"2698"
],
"type":"item_image",
"id":1,
"account":"\/api\/accounts\/2",
"name":"63495ac9a8688_60283-min.jpg",
"originalName":"60283-min.jpg",
"size":291983,
"mimeType":"image\/jpeg",
"publicPaths":{
"product_thumb_in_list":"https:\/\/example.com\/media\/cache\/resolve\/product_thumb_in_list\/63495ac9a8688_60283-min.jpg"
}
},
"item":"\/api\/accounts\/2\/items\/1"
},
{
"@id":"\/api\/accounts\/2\/items\/1\/images\/2",
"@type":"ItemImage",
"account":"\/api\/accounts\/2",
"file":{
"@id":"\/api\/accounts\/2\/files\/images\/2",
"@type":"https:\/\/schema.org\/MediaObject",
"dimensions":[
"3107",
"2668"
],
"type":"item_image",
"id":2,
"account":"\/api\/accounts\/2",
"name":"63495ac9ab8b9_60283_alt1-min.jpg",
"originalName":"60283_alt1-min.jpg",
"size":783721,
"mimeType":"image\/jpeg",
"publicPaths":{
"product_thumb_in_list":"https:\/\/example.com\/media\/cache\/resolve\/product_thumb_in_list\/63495ac9ab8b9_60283_alt1-min.jpg"
}
},
"item":"\/api\/accounts\/2\/items\/1"
}
],
"specifics":[
]
}
],
"hydra:totalItems":1
}
This is the pattern:
{
"@context":"\/api\/contexts\/Item",
"@id":"\/api\/accounts\/2\/items",
"@type":"hydra:Collection",
"hydra:totalItems":12,
"hydra:member":[
{
"@id":"@[email protected](\"\/api\/accounts\/2\/items\/\")",
"@type":"Item",
"id":"@integer@",
"account":"\/api\/accounts\/2",
"sku":"@string@",
"title":"@string@",
"shortDescription":"@string@",
"description":"@string@",
"variable":"@boolean@",
"itemVariants":[
],
"images":[
{
"@id":"@[email protected](\"#\/api\/accounts\/2\/items\/\\d+\/images\/\\d+#\")",
"@type":"ItemImage",
"account":"\/api\/accounts\/2",
"file":{
"@id":"@[email protected](\"#\/api\/accounts\/2\/files\/images\/\\d+#\")",
"@type":"https:\/\/schema.org\/MediaObject",
"dimensions":[
"@string@",
"@string@"
],
"type":"item_image",
"id":"@integer@",
"account":"\/api\/accounts\/2",
"name":"@string@",
"originalName":"@string@",
"size":"@integer@",
"mimeType":"@string@",
"publicPaths":{
"product_thumb_in_list":"@[email protected]()"
}
},
"item":"@[email protected](\"\/api\/accounts\/2\/items\/\")"
},
"@array_previous_repeat@"
],
"specifics":[
]
},
"@array_previous_repeat@"
]
}