| Q | A
| --------------------| ---------------
| PHPUnit version | 6.1.0
| PHP version | 7.1.0
| Installation Method | Composer
Hello,
I use the _PHPUnit assert functions_ to write feature tests of APIs with Behat. So, the assert assertJsonStringEqualsJsonString is very useful.
The problem is: since version 6, the exception throwed when this assert fails do not show the _diff_ anymore like version 5.
Output using version 5:
Failed asserting that two objects are equal.
--- Expected
+++ Actual
@@ @@
stdClass Object (
'message' => 'Validation Failed'
'details' => Array (
0 => stdClass Object (
'field' => 'name'
- 'message' => 'The name must no be blank.'
+ 'message' => 'The name must not be blank.'
'parameters' => stdClass Object (...)
)
1 => stdClass Object (
'field' => 'email'
- 'message' => 'The email must no be blank.'
+ 'message' => 'The email must not be blank.'
'parameters' => stdClass Object (...)
)
2 => stdClass Object (
'field' => 'role'
- 'message' => 'The role must no be blank.'
+ 'message' => 'The role must not be blank.'
'parameters' => stdClass Object (...)
)
)
)
Output using version 6:
Failed asserting that '{"message":"Validation Failed","details":[{"field":"name","message":"The name must not be blank.","parameters":{"value":"null"}},{"field":"email","message":"The email must not be blank.","parameters":{"value":"null"}},{"field":"role","message":"The role must not be blank.","parameters":{"value":"null"}}]}' matches JSON string "{
"message": "Validation Failed",
"details": [
{
"field": "name",
"message": "The name must no be blank.",
"parameters": {
"value": "null"
}
},
{
"field": "email",
"message": "The email must no be blank.",
"parameters": {
"value": "null"
}
},
{
"field": "role",
"message": "The role must no be blank.",
"parameters": {
"value": "null"
}
}
]
}". (PHPUnit\Framework\ExpectationFailedException)
I tested it also using _PHPUnit test case_ and the diff is also not showed.
Is that an intentional change of assertJsonStringEqualsJsonString or a bug?
Thank you very much.
PHPUnit 6.0 is no longer supported. Does the problem exist in PHPUnit 6.1?
I've updated to 6.1.0, but the problem persists :/
@sebastianbergmann I have the same problem, PHP 7.1, PHPUnit 6.1.3, installed by Composer, used in Behat context for assertions - neither assertJson* nor assertEquals produce diff when failing comparison.
This is most likely related to https://github.com/sebastianbergmann/phpunit/pull/2241.
However, I do not think that it was intentional that the diff stopped working.
@Sazpaimon (or @kalenp): Can you please have a look at this?
@fefas @thunderer Does https://github.com/sebastianbergmann/phpunit/pull/2708 solve this issue for you?
Hello @sebastianbergmann.. I've just tested here using the code from evgpisarchik/phpunit:issue_2654 and it works! Very much thank you @evgpisarchik for fixing that!
So, this issue can be closed after merging #2708
In what PHPUnit version has this fix been released?
Most helpful comment
Hello @sebastianbergmann.. I've just tested here using the code from
evgpisarchik/phpunit:issue_2654and it works! Very much thank you @evgpisarchik for fixing that!So, this issue can be closed after merging #2708