We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
If I have array response like this
[ { "id": "33", "title": "Google", "created_at": "2014-02-08 03:09:31", "updated_at": "2014-02-08 03:09:31" }, { "id": "34", "title": "Twitter", "created_at": "-0001-11-30 00:00:00", "updated_at": "2014-08-03 14:21:33" } ]
I should be able to check array values without knowing its keys, so I could check that item I'm looking for is inside of array:
<?php $I->seeResponseContainsJson([['title' => 'Twitter']]); // should pass ?>
Especially useful if there is root element:
{"companies": [ { "id": "33", "title": "Google", "created_at": "2014-02-08 03:09:31", "updated_at": "2014-02-08 03:09:31" }, { "id": "34", "title": "Twitter", "created_at": "-0001-11-30 00:00:00", "updated_at": "2014-08-03 14:21:33" } ] }
<?php $I->seeResponseContainsJson([['title' => 'Twitter']]); // should pass $I->seeResponseContainsJson([['title' => 'Twitter'], ['title' => 'Google']]); // should pass $I->seeResponseContainsJson(['companies' => [['title' => 'Twitter'], ['title' => 'Google']]]); // should pass ?>
The text was updated successfully, but these errors were encountered:
Actually, in some cases, I would like to have the correct order... for instance when testing that my "order by" query returns the right order
Sorry, something went wrong.
It would be a backwards compatibility break now.
To achieve your goal, you could use seeXmlResponseMatchesXpath for each item of array.
@Lambik you can test sorting in the following way:
$res = $I->sendGet('/api/endpoint'); $json = Json::decode($res); $I->assertEquals(123, $json[0]['id']); $I->assertEquals(456, $json[1]['id']);
No branches or pull requests
If I have array response like this
I should be able to check array values without knowing its keys, so I could check that item I'm looking for is inside of array:
Especially useful if there is root element:
The text was updated successfully, but these errors were encountered: