Skip to content
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

[9.x] Make assertPath() accepts Closure #41409

Merged
merged 2 commits into from
Mar 10, 2022
Merged

[9.x] Make assertPath() accepts Closure #41409

merged 2 commits into from
Mar 10, 2022

Conversation

villfa
Copy link
Contributor

@villfa villfa commented Mar 9, 2022

Hi,

I propose to modify AssertableJsonString::assertPath() in order to ease the way to write tests:

$this
    ->getJson('/api/whatever')
    ->assertOK()
    ->assertJsonPath('data.created_at', fn($date) => $date !== null)
    ->assertJsonPath('data.name', fn($name) => strlen($name) > 0)
;

At first I thought of adding a new method, but after struggling to find a right name, I realized that accepting closures in assertPath would not cause any BC break.

@villfa villfa changed the title Make assertPath() accepts Closure [9.x] Make assertPath() accepts Closure Mar 9, 2022
@BrandonSurowiec
Copy link
Contributor

I think it is an awesome addition.

@villfa villfa marked this pull request as ready for review March 10, 2022 08:56
@taylorotwell taylorotwell merged commit f5fe63f into laravel:9.x Mar 10, 2022
@villfa villfa deleted the patch-1 branch March 10, 2022 16:14
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.

3 participants