A bunch of assertions in WebTestBase are inconsistent with the other assertions:
a) Quite a few do not have $group parametres:
assertThemeOutput() and assertFieldByName() and assertNoFieldByName() and assertFieldById() and assertNoFieldById() and assertFieldChecked() and assertNoFieldChecked() and assertOption, assertNoOption, assertOptionSelected, assertNoOptionSelected, assertResponse, assertNoResponse(), assertMail
b) assertMailString doesn't even let you pass in your own message, much less group. Should have $message and $group.
c) assertMailPattern has $message but it is ignored. Should let you pass in $message and $group.
Comment | File | Size | Author |
---|---|---|---|
#11 | assertion_params-1817144-11.patch | 24.48 KB | kbasarab |
#11 | interdiff.txt | 3.17 KB | kbasarab |
#9 | assertion_params-1817144-9.patch | 22.13 KB | kbasarab |
#9 | interdiff.txt | 6.15 KB | kbasarab |
#7 | assertion_params-1817144-7.patch | 20.79 KB | kbasarab |
Comments
Comment #1
kbasarab CreditAttribution: kbasarab commentedComment #3
kbasarab CreditAttribution: kbasarab commentedThis should fix test fails.
Comment #4
jhodgdonThanks, this looks mostly really good! I was not sure why the parameter here was $other instead of the standard $group though?
I have a feeling that was just a typo.
This one is missing a space in $message ='':
Also, a couple of the new default $group parameters changed what had tacitly been the default before. For instance, assertMailString now has a default of 'E-mail', but it never used a group before, so it would have had assertTrue's generic default of 'Other'. I don't think this patch should probably try to change existing tacit defaults? maybe... I guess it's also good if all the mail-related asserts have the same default group? I'm undecided.
Comment #5
kbasarab CreditAttribution: kbasarab commentedthe $other is my fault. I'll fix that on the next fix.
The new $group parameters aren't actually new:
If you look at the return statement being replaced the $group parameter was default defined in the return statement. This patch goes with the standard of other assertions in allowing the user to change the $group parameter but still providing a default.
Comment #6
jhodgdonRE #5 $group params - I saw that on *some* of the functions, but others seemed to be added with 'E-Mail' as the default that didn't pass 'E-Mail' in previously (so they were defaulting to 'Other').
Comment #7
kbasarab CreditAttribution: kbasarab commentedThis patch changes $ group and takes the two that did not have $group parameters before and changes them back to 'Other'.
Comment #8
jhodgdonWow, I don't know how the tests passed on this patch. There's a typo in assertMailString():
format_stringt -> format_string
I guess that assertMailString() must not actually be used anywhere in our core tests.
The only other thing I noticed was one spot where this patch removed the blank line in documentation between the @param section and the @return section. There should always be a blank line in there.
Other than that, it looks good!
Comment #9
kbasarab CreditAttribution: kbasarab commentedRerolls to current head and then fixes typo and adds new lines between @param and @return statements.
Comment #10
jhodgdonThanks! I think this is *almost* good to go.
I just applied the patch, and took a look at all of the test classes' functions that started with "assert" to see if they are all now consistently having $message and $group parameters. They're almost all great!
I found just a few more spots that I think need attention:
a) WebTestBase
There is no default for $group but the docs say it's optional... It is a helper function, so it's probably OK that it not have a default for $group, but the docs should not say that $group is optional. I think the right fix is just to take (optional) out of the docs.
b) The same also applies for assertUniqueTextHelper().
c) assertMailString() needs a space in its signature line in the $message parameter:
d) TestBase::assertIdenticalObject() has a default of '' for the $group parameter, and this paramter is not even passed to assertTrue() at the bottom of the function. So it needs to be fixed in the same way you already fixed the other methods.
Comment #11
kbasarab CreditAttribution: kbasarab commentedFixed group documentation in A. Overlooked that in changing all the groups to optional.
b - Corrected also.
c - Added space
d - Added group parameter to pass as we did on other methods.
Comment #12
jhodgdonYeah! Assuming the test bot agrees, this is ready to go!
Note to final reviewer/committer: The issue summary outlines the problem... The idea of this patch is that all assert functions in the test base classes will now have both $message and $group parameters, so these can be overridden by the calling tests. All of the functions had implicit defaults for these before, but in many cases they could not be overridden. Now they can.
The patch has been carefully constructed in this issue with defaults that should not change the implicit defaults that were present before, which is why some of them have $group = 'Browser' etc. rather than the usual $group = 'Other'.
Hope these notes help... thanks kbasarab for your persistence and attention to detail on this issue! Nice work!
Comment #13
xjmOh, excellent issue. Thanks everyone!
Comment #14
webchickThis looks like a lovely patch of loveliness.
Committed and pushed to 8.x.
We should likely have a change notice for this.
Comment #15
jhodgdonI'm actually not sure this does need a change notification. We were very careful in this patch to preserve exactly the previous behavior of every assertion message, while adding the ability to pass $message and $group to all of the functions if desired. So in reality, there is nothing that any test class would need to do to their tests in response to this change, and their tests should behave exactly the same as they used to.
I thought we only needed change notifications if developers or someone else would need to change something (code, docs, etc.)?
Comment #16
xjm@timplunkett and I talked about this briefly and we agree that it probably doesn't actually need a change notification. There isn't really an API change so much as a few smarter defaults and a couple fixes to oddball assertions along the way.
Comment #17
jhodgdon