I've just gotten started with unit testing (I'm reading Laravel Testing Decoded by Jeffrey Way). I'm not sure how to test the "exists" validation rule in isolation since it queries the database. I think maybe I need to mock the database query somehow? If so, I'm not sure how to do that.
To be clear, I want to test that business rules are being enforced, not to test that the validator is working correctly. Also, I'm doing validation in the model with Ardent so it's the model that is being testing.
As an example, the "required" rule is straightforward to test. You fill every field with valid data, except for the one you are testing which is left null. Then you assert that validation failed. (The book has examples of this) But testing "exists" or "unique" needs to touch the database.