joshgaber / NovaUnit

Unit testing suite for Laravel Nova, built to extend PHPUnit
https://joshgaber.github.io/NovaUnit
MIT License
66 stars 23 forks source link

Add type assertion and expose component #62

Open tobias-grasse opened 1 year ago

tobias-grasse commented 1 year ago

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.