Skip to content

Explicit message for "json node should have :nb elements" - #31

Closed
jdeniau wants to merge 1 commit into
soyuka:mainfrom
jdeniau:patch-1
Closed

jdeniau wants to merge 1 commit into
soyuka:mainfrom
jdeniau:patch-1

Conversation

@jdeniau

@jdeniau jdeniau commented May 13, 2024 •

Copy link
Copy Markdown
Q A
Branch? main
Bug fix? no
New feature? yes
Deprecations? no
Tickets N/A
License MIT
Doc PR N/A

Make the output of @Then the JSON node :node should have :count element(s) more explicit

Here the diff of the before / after output:

 - The element '2' is not equal to '1'
 + The JSON node "some.node" contains 2 elements (1 expected).

@Jean-Beru

Copy link
Copy Markdown
Collaborator

Good catch @jdeniau ! It seems that theJsonNodeShouldContain and theJsonNodeShouldNotContain methods also don't have an explicit message. Can you update them ?

@jdeniau

jdeniau commented Jun 4, 2024

Copy link
Copy Markdown
Author

Hi @Jean-Beru .

I created #33 for that 👍

@Jean-Beru Jean-Beru left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a unit test too ?

$this->assertSame(
$count,
$actualCount,
'The node "'.$node.'" contains '.$actualCount.' elements ('.$count.' expected).'

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'The node "'.$node.'" contains '.$actualCount.' elements ('.$count.' expected).'
sprintf("The node '%s' contains %d elements, %d expected.", $node, $actualCount, $count)

$count,
$actualCount,
'The node "'.$node.'" contains '.$actualCount.' elements ('.$count.' expected).'
);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a unit test too ?

@Jean-Beru

Copy link
Copy Markdown
Collaborator

Thanks @jdeniau, and sorry for the long wait.

I could not push to your branch, so I opened #45. It keeps your commit and applies the review: the suggested message (with element(s), since the count can be 1) and a unit test.

@Jean-Beru Jean-Beru closed this Oct 16, 2026
@jdeniau
jdeniau deleted the patch-1 branch October 16, 2026 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants