Repository navigation
Conversation
c41fecc to
818c276
Compare
| $this->assertContains( | ||
| $text, | ||
| (string) $actual, | ||
| 'The node "'.$node.'" does not contain the expected text "'.$text.'" (found "'.$printedActual.'")' |
There was a problem hiding this comment.
The node '%s' should contain '%s', but it is '%s'. is more concise. WDYT ?
| $actual = $this->inspector->evaluate($json, $node); | ||
|
|
||
| $this->assertContains($text, (string) $actual); | ||
| $printedActual = \strlen($actual) > 50 ? substr($actual, 0, 50).'[…]' : $actual; |
There was a problem hiding this comment.
Truncating the value might make debugging more difficult.
| $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.'")' | ||
| ); |
There was a problem hiding this comment.
(same comments as previous)
| (string) $actual, | ||
| 'The node "'.$node.'" does contain "'.$text.'" while it should not (found "'.$printedActual.'")' | ||
| ); | ||
| } |
There was a problem hiding this comment.
Can you add a unit test too ?
|
It does, but the value when you use "contain" might be a huge bloc of text. Maybe we can set the limit to 200 or 500 though.
…-------- Message d'origine --------
Le 04/06/2024 22:00, Hubert Lenoir a écrit :
@Jean-Beru commented on this pull request.
---------------------------------------------------------------
In [src/Context/JsonContext.php](#33 (comment)):
> @@ -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.'")'
The node '%s' should contain '%s', but it is '%s'. is more concise. WDYT ?
---------------------------------------------------------------
In [src/Context/JsonContext.php](#33 (comment)):
> @@ -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;
Truncating the value might make debugging more difficult.
---------------------------------------------------------------
In [src/Context/JsonContext.php](#33 (comment)):
> + $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.'")'
+ );
(same comments as previous)
—
Reply to this email directly, [view it on GitHub](#33 (review)), or [unsubscribe](https://github.com/notifications/unsubscribe-auth/AAKVNRPOVMPIXY3VTD26TATZFYMFLAVCNFSM6AAAAABIYFSHBCVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDAOJXGI3TOMZZGE).
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Sure ! We can keep this value uncut for now (like in other contexts) and create an other PR to truncate it. Maybe using the verbosity ? |
|
Thanks @jdeniau, and sorry for the long wait. I could not push to your branch, so I opened #44. It keeps your commit and applies the review: concise messages, no truncation, and unit tests for both steps (single and table variants). Truncating long values based on the verbosity level needs a dedicated PR. I plan it for 4.0. |
See #31
Added better message for
theJsonNodeShouldContain:and for
theJsonNodeShouldNotContain