@rugavy Yeah, I’d approach it in the similar way. In fact, I have done in one of my own applications.
It’s a video on demand site so there’s lots around what users can and can’t do based on various conditions. Is the user a guest? Has the user rented the title? Is the user subscribed to the channel the title belongs to? These have their own tests named as such, i.e.
-
test_guest_cannot_see_video -
test_user_cannot_see_video -
test_user_can_see_video_if_has_active_rental -
test_user_cannot_see_video_if_rental_has_expired -
test_user_can_see_video_if_subscribed_to_channel -
test_user_cannot_see_video_if_subscription_has_expired
Under the hood, these use Laravel policies, but I prefer testing the logic in situ rather than writing unit tests for a policy class.