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

[11.x] Allow enums to be passed to AssertableJson where methods #52360

Merged

Conversation

patrickomeara
Copy link
Contributor

Like a lot of developers, I hate strings. Strings are for users.

Enums give me type safety for speling mistakes, and generally make me feel more comfortable about the world and my code.

This PR brings the where, whereNot and whereContains methods of the AssertableJson class in to line with their Eloquent cousins by accepting enums.

This change is backward compatible.

$this->getJson('/users/1')
    ->assertJson(fn (AssertableJson $json) => $json->where('role', UserRole::Developer->value))

// becomes
$this->getJson('/users/1')
    ->assertJson(fn (AssertableJson $json) => $json->where('role', UserRole::Developer))

@driesvints
Copy link
Member

Please rebase so tests pass, thanks!

@driesvints driesvints marked this pull request as draft August 2, 2024 11:55
@patrickomeara patrickomeara marked this pull request as ready for review August 2, 2024 21:19
@cosmastech
Copy link
Contributor

Strings are for users.
🔥

@taylorotwell taylorotwell merged commit fd8e150 into laravel:11.x Aug 5, 2024
29 checks passed
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.

4 participants