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

Add type assertion and expose component #62

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

tobias-grasse
Copy link

Hi @joshgaber, thanks for this handy helper package. I came across the use-case to assert that the defined field has the given Nova field type. Useful e.g. to assert that an E-mail is rendered with the dedicated Laravel\Nova\Fields\Email component instead of a generic Text component.

I've added tests for the new method, as well as an InvalidFieldTypeException to have a nicer error message if the assertion receives an invalid class-string.

I also think that publicly exposing MockComponent::$component might come in handy for cases where we want to perform custom assertions on the actual component rather than the MockComponent. If access is restricted for a reason, I can drop those from the PR.

Signed-off-by: Tobias Grasse <tg@glancr.de>
Allows to test if a given MockFieldElement instance has the given type.

Signed-off-by: Tobias Grasse <tg@glancr.de>
Allows developers to run arbitrary assertions against the component or field.

Signed-off-by: Tobias Grasse <tg@glancr.de>
@robertmarney
Copy link
Collaborator

Hey @tobias-grasse

As a head-up this package was marked as abandoned on packagist recently and has been replaced with a new fork (with @joshgaber's blessing)

You can find it here: Packagist and GitHub

Feel free to submit your PR over there 🙏

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.

2 participants