Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.6k
[JsonPath] AddJsonPathAssertionsTrait
and related constraints#60105
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation
4325a17
to59965aa
Comparesrc/Symfony/Component/JsonPath/Tests/Test/JsonPathAssertionsTraitTest.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
59965aa
to86cd504
CompareUh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/JsonPath/Tests/Test/JsonPathAssertionsTraitTest.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
86cd504
to5afe345
Comparealexandre-daubois commentedApr 1, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@stof All your comments are addressed, I pushed a new version with "standalone" constraints as done in BrowserKit. |
JsonPathAssertionsTrait
JsonPathAssertionsTrait
and related constraintsJsonPathAssertionsTrait
and related constraintsJsonPathAssertionsTrait
and related constraintsJsonPathAssertionsTrait
and related constraintsJsonPathAssertionsTrait
and related constraints… (alexandre-daubois)This PR was merged into the 7.3 branch.Discussion----------[JsonPath] Add two utils methods to `JsonPath` builder| Q | A| ------------- | ---| Branch? | 7.3| Bug fix? | no| New feature? | yes| Deprecations? | no| Issues | -| License | MITSmall DX improvements that goes with#60105 and#60083.This PR adds two new methods, `first()` and `last()`, added to JsonPath builder. This voluntary reminds methods from the DomCrawler component. The goal is not to add every possible method, but I think `first()` and `last()` are common enough to be added.I also propose to rename `anyIndex()` to `all()`.```php$path = new JsonPath();// Get the first user of the collection$path = $path->key('users')->first();``````php$path = new JsonPath();// Get the last user of the collection$path = $path->key('users')->last();``````php$path = new JsonPath();// Get all users of the collection$path = $path->key('users')->all();```Commits-------3bc3559 [JsonPath][DX] Add utils methods to `JsonPath` builder
JsonPathAssertionsTrait
and related constraintsJsonPathAssertionsTrait
and related constraintsUh oh!
There was an error while loading.Please reload this page.
5afe345
tobbe4a62
CompareThere 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.
API Platform has a usefulassertJsonContains
method that matches an array subset.
You can addassertJsonPathSubset
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
bbe4a62
tof03afed
Compare@GromNaN indeed, good idea of feature! I'll have a look at it a bit later when I have a some time to dig the subject on why Sebastian deprecated the feature in PHPUnit first 🙂 Thanks for the review! |
f03afed
to60cba45
CompareThank you@alexandre-daubois. |
422893b
intosymfony:7.3Uh oh!
There was an error while loading.Please reload this page.
Let's leverage JsonPath in test cases. I propose to add a new trait to ease testing JSON strings against JsonPath: