-
Notifications
You must be signed in to change notification settings - Fork 19
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
Better messages for "JSON node should (not) contain" #33
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -226,7 +226,13 @@ public function theJsonNodeShouldContain($node, $text): void | |
|
||
$actual = $this->inspector->evaluate($json, $node); | ||
|
||
$this->assertContains($text, (string) $actual); | ||
$printedActual = \strlen($actual) > 50 ? substr($actual, 0, 50).'[…]' : $actual; | ||
|
||
$this->assertContains( | ||
$text, | ||
(string) $actual, | ||
'The node "'.$node.'" does not contain the expected text "'.$text.'" (found "'.$printedActual.'")' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
); | ||
} | ||
|
||
/** | ||
|
@@ -252,7 +258,13 @@ public function theJsonNodeShouldNotContain($node, $text): void | |
|
||
$actual = $this->inspector->evaluate($json, $node); | ||
|
||
$this->assertNotContains($text, (string) $actual); | ||
$printedActual = \strlen($actual) > 50 ? substr($actual, 0, 50).'[…]' : $actual; | ||
|
||
$this->assertNotContains( | ||
$text, | ||
(string) $actual, | ||
'The node "'.$node.'" does contain "'.$text.'" while it should not (found "'.$printedActual.'")' | ||
); | ||
Comment on lines
+261
to
+267
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (same comments as previous) |
||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add a unit test too ? |
||
|
||
/** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Truncating the value might make debugging more difficult.