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

Change print_r to var_export in REST/seeResponseContainsJson #1210

Closed
michaelpopok opened this issue Jul 15, 2014 · 1 comment
Closed

Change print_r to var_export in REST/seeResponseContainsJson #1210

michaelpopok opened this issue Jul 15, 2014 · 1 comment
Milestone

Comments

@michaelpopok
Copy link

@michaelpopok michaelpopok commented Jul 15, 2014

I have run into issue with json encoding of bigint values as strings on 32-bit OS and could not understand why assert in function seeResponseContainsJson returns false when the output is exactly the same:

[PHPUnit_Framework_ExpectationFailedException] Response JSON contains provided
- Array
(
[id] => 1
[name] => Venue1
)
+ Array
(
[id] => 1
[name] => Venue1
)
Failed asserting that false is true.

public function seeResponseContainsJson($json = array())
    {
        $resp_json = json_decode($this->response, true);
        \PHPUnit_Framework_Assert::assertTrue(
            $this->arrayHasArray($json, $resp_json),
            "Response JSON contains provided\n"
            ."- ".print_r($json, true)
            ."+ ".print_r($resp_json, true)
        );
    }

With var_export function instead of print_r it would give me the output where I could see the actual difference:

[PHPUnit_Framework_ExpectationFailedException] Response JSON contains provided
- array (
'id' => 1,
'name' => 'Venue1',
)+ array (
'id' => '1',
'name' => 'Venue1',
)
Failed asserting that false is true.

@DavertMik
Copy link
Member

@DavertMik DavertMik commented Jul 15, 2014

Yeah, looks reasonable

@DavertMik DavertMik added this to the 2.0.4 milestone Jul 23, 2014
@DavertMik DavertMik closed this in 68bc1e3 Aug 1, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.