-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
[9.x] Add view data assertions to TestView
#43923
Conversation
- `assertViewHas()` - `assertViewHasAll()` - `assertViewMissing()` these methods are all available on the `TestResponse`, but not currently `TestView`. These assertions can be more helpful to test the workings of the component, and not reliant on how the data actually gets displayed on the view side of things.
If this is a test view object, is it a bit redundant to say |
possibly, although it might be nice to explicitly know we're targeting the these methods where copied and tweaked from the either way, your call. happy to make the changes if desired. |
Tiny, tiny papercut, but if this is new code, I'd love to be able to check a piece of view data is explicitly |
this just got deployed today, so unfortunately can't change it now. I'm trying to think how this would work, and AFAIK in PHP you can't tell if an argument is passed, or if it's using the default value. I feel like we'd have to separate out a separate method for checking simply if the variable is passed, and one for if the variable has a specific value. |
Yeah, no worries. Just something in the rare times I've actually passed in I've seen other languages use a constant in this case. For example, Objective-C uses a |
very interesting.... I feel like this could be super beneficial in numerous places on the framework. how do you check for the constant? aren't you still comparing by value? what value do you assign the constant? |
Yes, its actual value could be a bit tricky as a simple value could pose the same problem. I suppose that's the benefit of a language constant. Nonetheless, something random would have a lower hit rate than |
assertViewHas()
assertViewHasAll()
assertViewMissing()
these methods are all available on the
TestResponse
, but not currentlyTestView
. These assertions can be more helpful to test the workings of the component, and not reliant on how the data actually gets displayed on the view side of things.