Skip to content

Add test documentation for the component #21090

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

Open
wants to merge 2 commits into
base: 7.3
Choose a base branch
from

Conversation

vinceAmstoutz
Copy link
Contributor

Updates the documentation to document JsonPathAssertionsTrait and related constraints (closes #20977).

Complete the previous work done in #21078.

@vinceAmstoutz vinceAmstoutz changed the title docs(json-path): add testing part doc for the component [JsonPath] Add test documentation for the component Jun 17, 2025
Updates the documentation to document `JsonPathAssertionsTrait` and related constraints (closes symfony#20977). Complete the previous work done in symfony#21078.
@vinceAmstoutz vinceAmstoutz force-pushed the docs/json-path/add-assertions-and-trait-the-component-doc branch from e4e14e1 to b1c2340 Compare June 17, 2025 08:51
Co-authored-by: Oskar Stark <oskarstark@googlemail.com>
@vinceAmstoutz vinceAmstoutz requested a review from OskarStark June 17, 2025 09:32
Copy link
Member

@javiereguiluz javiereguiluz left a comment

Choose a reason for hiding this comment

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

Nice work Vincent! Thanks.

The trait provides the following assertion methods:

* :method:`Symfony\\Component\\JsonPath\\Test\\JsonPathAssertionsTrait::assertJsonPathCount`
Asserts that the number of elements found by the JSONPath expression matches an expected count::
Copy link
Member

Choose a reason for hiding this comment

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

There's a minor RST syntax here. The contents of list items must use the same indentation and the code inside it must be indeneted by 4 spaces. E.g., the first item here should be:

* :method:`Symfony\\Component\\JsonPath\\Test\\JsonPathAssertionsTrait::assertJsonPathCount`
  Asserts that the number of elements found by the JSONPath expression matches an expected count::

      $json = '{"a": [1, 2, 3]}';
      self::assertJsonPathCount(3, '$.a[*]', $json);

self::assertJsonPathCount(3, '$.a[*]', $json);

* :method:`Symfony\\Component\\JsonPath\\Test\\JsonPathAssertionsTrait::assertJsonPathEquals`
Asserts that the result of a JSONPath expression is equal (``==``) to an expected value. This assertion uses type coercion::
Copy link
Member

Choose a reason for hiding this comment

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

I'd use this to make sure nobody misses this:

Asserts that the result of a JSONPath expression is equal to an expected value.
The comparison uses ``==`` (type coercion) instead of ``===``::

self::assertJsonPathEquals(['1'], '$.a[0]', $json);

* :method:`Symfony\\Component\\JsonPath\\Test\\JsonPathAssertionsTrait::assertJsonPathNotEquals`
Asserts that the result of a JSONPath expression is not equal (``!=``) to an expected value::
Copy link
Member

Choose a reason for hiding this comment

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

I'd do the same reword here as in the previous example of euqals.

@carsonbot carsonbot changed the title [JsonPath] Add test documentation for the component Add test documentation for the component Jun 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[JsonPath] Add JsonPathAssertionsTrait and related constraints
4 participants