You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Scenario Outline: Event LIST: Response StructureWhen I get the event list
Then the response code is 200
And the response body contains JSON:
""" [ { "id": "@variableType(string)", "calendar_id": "@variableType(string)", "custom_data": "@variableType(object)" } ]"""
@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:
behat-api-extension/src/Context/ApiContext.php
Line 1198 in 099d66b
As it parses both "[]" and "{}" values into an associative array, therefore, making the assertion for variable type object not working.
The text was updated successfully, but these errors were encountered: