Closed (fixed)
Project:
Drupal core
Version:
8.9.x-dev
Component:
phpunit
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
23 Apr 2020 at 19:00 UTC
Updated:
11 May 2020 at 09:34 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
jungleComment #3
dwwGeneral +1. Haven't reviewed yet, but fixing the title.
Comment #4
jungle@dww, thanks, nice catch!
Comment #5
dwwThe previous code was wrong, too, but the assertion message shouldn't be in t().
Possible scope creep, but it's a bit weird the first message uses "we're" and wraps whole thing in double quotes, while the 2nd message uses "we are" and single quotes. I think we should standardize on 'we are' with single quotes...
Again here.
And here.
I dunno. Don't listen to me. I almost never get scope questions right. If it were me, I'd fix these to be consistent while we're already touching the files. Someone else will probably say we should jump through all the hoops to have a separate issue for this. /shrug
More scope creep, but to disambiguate this message from the one a few lines up, I think it should mention "cron". Something like:
"Running cron successfully re-created the .htaccess file in the files directory."
/shrug
After applying the patch (on the 8.9.x branch), I'm still seeing these:
However, on the 9.1.x branch, this patch removes everything. Maybe that's good enough. Unclear how far this will be backported.
Maybe needs work for the last point (if this will be backported that far). The other points are possibly scope creep that may require follow-ups. I hope not. But please don't spend time on them until we get confirmation from core folks on desired scope.
Thanks!
-Derek
Comment #6
mondrakeFor the same reasons outlined in #3130811: Remove redundant $message from assert(Not)InstanceOf calls, for points 1-5 in #5, my suggestion would be to just remove the messages and let standard PHPUnit manage them. This will take most complexity away.
With regards to #5.6, IMHO we should just target 9.1 and 9.0 now. If committers later want so, they will ask for a backport patch. See #3128905: Replace assert* involving an instanceof operator with assertInstanceOf()/assertNotInstanceOf().
Comment #7
jungleThanks @dww for reviewing, and @mondrake for commenting.
Re #5.6
assertTrue(is_file($file->getFileUri()), $message);andassertFalse(is_file($file->getFileUri()), $message);So no need to address and can not, and patch in #2 is ok to be backported to 8.x.
Comment #8
longwaveAs suggested in #6 I agree that most of the assertion messages are useless here and generally it would be better to use the default PHPUnit failure message, so I have removed them all with the exception of ResolvedLibraryDefinitionsFilesMatchTest which I think is still a helpful message. However, PHPUnit messages describe the failure as opposed to the success, so I have inverted the message here.
Comment #9
mondrakeRTBC, removes occurrences of assert* calls using calls of is_file().
We will need a followup here to check if the remaining usages of the $message argument in calls to assertFile(Not)Exists can be removed, searching for
assertFile(?:Not)?Exists\(.*,.*[\'"]returns 27 occurrences.Comment #13
catchCommitted/pushed to 9.1.x and backported back to 8.9.x, thanks!
fwiw I'm +1 to removing custom assertion messages from the majority of our assertions - a lot of the assertion messages were added when we originally added Simpletest to core, and have just been ported through to phpunit.