Skip to content

Diff problem with assertJsonStringEqualsJsonString in version 6.* #2654

Closed
@fefas

Description

@fefas
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/bugSomething is broken

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions