Description
In project I'm currently working on, we had a following scenario step:
And json response should match:
"""
{
"limit": 10,
"offset": 0,
"count": 1,
"wins": @array@.count(1)
}
"""
and it was throwing me a very weird error: Type pattern "@array@" is not supported by TextMatcher. (RuntimeException)
.
After investigation it turned out that php-matcher/src/Matcher/Pattern/Assert/Json.php:33
can't recognize this pattern as a valid json value (because of @array@.count(1)
) and thats why JSONExpander is being ignored.
The same problem seems to be found here: #83
Perfect solution would be to update Json::transformPattern($pattern)
method, to transform patterns with expanders into native strings:
before transformation:
@array@.count(1)
after transformation:
"@array@.count(1)"
Of course currently this issue can be solved by making sure that all patterns with expanders are stored just like in following example:
And json response should match:
"""
{
"limit": 10,
"offset": 0,
"count": 1,
"wins": "@array@.count(1)"
}
"""