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
a assertion that checks for given keys in the json response.
my current code for that is..
/** * Assert that an API response contains the given keys. * * @param array|string $expected * @return static */ protected function seeJsonHasKeys($expected) { if (is_string($expected)) $expected = [$expected]; $response = json_decode($this->response(), true); $this->sortJson($expected); $this->sortJson($response); foreach ($expected as $key) { $expectedKey = trim(sprintf('"%s"', $key), '{}'); if ( ! str_contains(json_encode($response), $expectedKey)) { $this->fail(sprintf( "Dang! Expected key %s to exist in %s, but nope. Ideas?", $expectedKey, json_encode($response) )); } } return $this; }
The text was updated successfully, but these errors were encountered:
+1 This would be a very useful addition.
Sorry, something went wrong.
No branches or pull requests
a assertion that checks for given keys in the json response.
my current code for that is..
The text was updated successfully, but these errors were encountered: