Needs work
Project:
Drupal core
Version:
main
Component:
phpunit
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
18 Apr 2020 at 23:11 UTC
Updated:
9 Aug 2021 at 09:36 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
longwaveThis is the modernisation, deprecation testing for unused/untested methods to follow.
Comment #4
longwaveComment #5
msutharsComment #6
msutharsComment #7
mondrakeIn PHPUnit, the messages should explain the reason of the failure. These messages seem to be inherited from Simpletest, where they were describing what was being tested. So they should be negated IMHO. Normally I wouldn't bother, but in this case it's a trait used extensively and I think here they should be corrected.
Comment #8
longwaveAddressed #7, tried to make the messages more consistent as well.
Comment #9
mondrakeLooks good to me
Comment #10
xjmLooks like it needs a re-roll. Thanks!
Comment #11
xjmAlso, the changes in this patch do not look very BC. Can we deprecate the extra parameter and such, rather than changing the signatures? Etc.
Comment #12
mondrakeRerolled. IMHO it does not make any sense to go for deprecations here, at least for D9 - what's being removed are Simpletest-isms. They should have been deprecated before Simpletest was removed. But Simpletest has been removed already, and there's no point to do that now.
If this patch will ever be backported to D8 (and I see no strict need for that), then we may want to make some deprecation dance there and then; besides, this patch is introducing usage of PHPUnit-only assertions: if the trait is used also by Simpletest in D8, then we would need to ensure we will not be breaking anything.
Comment #13
xjmWe would definitely not backport this to D8. But the minor upgrade path from 9.0 -> 9.1 should be free of BC breaks, even for internal code. Even though SimpleTest isn't in core anymore, this stuff is.
Tagging for RM review.
Comment #14
xjmComment #15
xjmAlright, given that
WebAssert::assert()andAssertLegacyTrait::assert()don't actually even take$groupanymore, and thatassertTextHelper()also isn't doing anything with it, I was wrong and this is BC. If custom code is using the$groupparameter, they'd be doing so withfunc_get_args(), which will continue to work.However, what we're missing is notifying custom code that the
$groupparameter is unused. So if they're expecting it to put the test in a different group, it doesn't. Therefore, I still think we should@trigger_error()if anything other than aNULLvalue of$groupis passed -- especially forassertTextHelper(), but also for the other methods. This should have been done in the first place when it became dead code, but we should definitely fix it before silently removing the parameter from the signature.It might also make sense to scope this issue into one patch that deals with dead code
$group(maybe beyond the scope of just this trait) and another that deals with improving the not-dead code in the methods.I was going to say we should deprecate
assertTextHelper(), but looks like it already is.Why are we deleting all these docs? AFAIK we still don't hav a PHPCS sniff to ensure the message parameter is not translated, so these are still relevant. (I guess "half-relevant" since we've also moved away from
FormattableMarkupfor them as well.) The bit about "a default message will be displayed" is also still true.Thanks!
Comment #16
longwave#15.1 Added deprecation notices to all methods along the lines of #3160405: Deprecate overloading arguments to WebAssert methods to prevent conversions of legacy Simpletest test to carry over cruft now $group has been removed everywhere.
#15.2 Explicitly deprecated assertTextHelper(). Some of the other methods such as assertNoDuplicateIds() are entirely unused in core, I don't know if we want to keep supporting these either.
#15.3 Restored missing docs.
Comment #18
mondrakeComment #19
longwaveRerolled, and removed some more of the basic "default" messages, as the PHPUnit-provided ones are better anyway.
Comment #20
longwaveThe following list of methods don't seem used in kernel tests, which are the only type that calls this trait. I wonder if we should deprecate many if not all of these?
Comment #22
mondrake+1 for deprecating unused methods. This trait was introduced back in Simpletest times, I feel like most of the methods listed in #20 probably make sense in the context of functional tests, but there we have WebAssert now. So let's deprecate to remove in D10, and then if some have merit to stay someone will hopefully speak up.
Comment #23
longwaveOpened #3227335: Deprecate unused kernel test assertions in AssertContentTrait to deprecate the unused methods, this issue can remain to clean up what's left afterwards.