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

Diff problem with assertJsonStringEqualsJsonString in version 6.* #2654

Closed
fefas opened this Issue Apr 20, 2017 · 6 comments

Comments

3 participants
@fefas

fefas commented Apr 20, 2017

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.

@sebastianbergmann

This comment has been minimized.

Show comment
Hide comment
@sebastianbergmann

sebastianbergmann Apr 20, 2017

Owner

PHPUnit 6.0 is no longer supported. Does the problem exist in PHPUnit 6.1?

Owner

sebastianbergmann commented Apr 20, 2017

PHPUnit 6.0 is no longer supported. Does the problem exist in PHPUnit 6.1?

@fefas

This comment has been minimized.

Show comment
Hide comment
@fefas

fefas Apr 20, 2017

I've updated to 6.1.0, but the problem persists :/

fefas commented Apr 20, 2017

I've updated to 6.1.0, but the problem persists :/

@thunderer

This comment has been minimized.

Show comment
Hide comment
@thunderer

thunderer May 17, 2017

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

thunderer commented May 17, 2017

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

@sebastianbergmann

This comment has been minimized.

Show comment
Hide comment
@sebastianbergmann

sebastianbergmann Oct 13, 2017

Owner

This is most likely related to #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?

Owner

sebastianbergmann commented Oct 13, 2017

This is most likely related to #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?

@sebastianbergmann

This comment has been minimized.

Show comment
Hide comment
@sebastianbergmann

sebastianbergmann Oct 13, 2017

Owner

@fefas @thunderer Does #2708 solve this issue for you?

Owner

sebastianbergmann commented Oct 13, 2017

@fefas @thunderer Does #2708 solve this issue for you?

@fefas

This comment has been minimized.

Show comment
Hide comment
@fefas

fefas Oct 15, 2017

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

fefas commented Oct 15, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment