Open josep11 opened 1 year ago
Thanks for raising this issue. I have created a test locally that recreates the issue, and I will see if I can come up with a proper solution for it.
@christeredvartsen I believe for the solution we will need to pass along an alternative haystack variable (decoded body as a non-associative array) into the method ArrayContainsComparator::compare
and then in the foreach of that method check the $value
to see if it equal to "@variableType(object)". If that happens, then pick the alternative haystack.
I think that will work.
Hi all,
I found an issue when asserting the response body for a LIST endpoint. Discovered it because the endpoint is working as expected but the behat test were not passing.
Essentially the problem is that when using the step definition "And the response body contains JSON" in conjunction with an assertion for object "@variableType(object)" it's not working because the method ApiContext::assertResponseBodyContainsJson converts everything into an associative array.
Response returned by the API:
Behat test:
More background
Essentially the issue is with this line: https://github.com/imbo/behat-api-extension/blob/099d66bf84e17ab6713de00941dbe738376aaae9/src/Context/ApiContext.php#L1198 As it parses both "[]" and "{}" values into an associative array, therefore, making the assertion for variable type object not working.