joshgaber / NovaUnit

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

Field Assertion for Creation Rules and Update Rules #29

Closed joshua060198 closed 4 years ago

joshua060198 commented 4 years ago

What?

I've added assertion method to check for creation rules as well as update rules on a field.

Why?

First of all, thank you for creating such a nice package that helps me very much to do unit testing in Nova. But yesterday, I just realized, there are fields that have different rule upon creation or updating. So for this case, using assertHasRule won't work. And that is the reason I come up with this new assertion method.

How?

We can use the creationRules and updateRules attributes from the Field instance to check if it contains the given rule.

Testing

I also have added the corresponding test for both creation rule assertion and update rule assertion.

Final Notes

Hope this will help and sorry for my bad English :sweat_smile: .

joshgaber commented 4 years ago

@joshua060198 Hello! Thank you for submitting to my project! I'm sorry it has taken me so long to review your pull request. I have just a few small changes, and then I will add this to my next release.