[6.x] Add hasMacro methods to Eloquent Builder #30008
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adding 3 new public methods to the Eloquent Builder for convenience to allow tests to assert on whether or not the Builder class has global macros - or an instance of it, local macros - registered to it.
This will allow for tests where the assertion is looking to see if a macro method is registered without having to be concerned about the macro's specific implementation, as demonstrated.
It also allows for a more defensive style of coding against Builder macros, if you're that way inclined. For those times when you prefer to check that a macro is registered rather than handling the exception thrown when it isn't.