Skip to content
New issue

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

Implemented step theResponseShouldContainPartialJson #49

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

alexsegura
Copy link

Does not check the whole JSON response keys per keys, but only the ones expected.
Useful for time changing properties, for example

Probably like #47

Does not check the whole JSON response keys per keys, but only the ones expected.
Useful for time changing properties, for example
$keys = array_intersect($etalonKeys, $actualKeys);

foreach ($keys as $key) {
assertArrayHasKey($key, $etalon);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this does not make sense. you should assert what the response contain, not what the etalon contains

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right.

Alexandre Segura added 2 commits January 17, 2014 19:00
Improved step regex
Only keys of the etalon are checked
Implemented recursive array comparison
@alexsegura
Copy link
Author

Hey @stof please check my last commit, hope this is ok now

foreach ($expected as $key => $value) {
assertArrayHasKey($key, $actual);
if (is_array($value)) {
$this->assertArrayPartiallyEquals($expected[$key], $actual[$key]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need to assert that $actual[$key] is an array before calling the method to avoid a fatal error on the typehint

@alexsegura
Copy link
Author

Hello @stof sorry for the delay to fix this

I added assertions to avoid the fatal errors, does it look good ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants