Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Spotted in #3176200: Remove more uses of t() in assertNoText() we have assertions like this:
core/modules/views_ui/tests/src/Functional/FieldUITest.php
35: $this->assertNoText('Views test: Name [' . t('hidden') . ']');
The call to t() does nothing (except in the special case that translations are being tested).
Steps to reproduce
Proposed resolution
Remove the calls to t() and use plain strings where possible.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Comment | File | Size | Author |
---|---|---|---|
#19 | interdiff.3184493.15-19.txt | 2.16 KB | longwave |
#19 | 3184493-19.patch | 30.13 KB | longwave |
Comments
Comment #2
longwaveComment #3
longwaveComment #4
mondrakeLooks like we can have just a string here for expected, further avoiding concatenation. Also maybe since we touch here we can switch to
assertEquals
and remove usage of deprecatedassertEqual
.Comment #5
longwaveI also missed quite a few
Comment #6
ravi.shankar CreditAttribution: ravi.shankar at OpenSense Labs commentedComment #7
ravi.shankar CreditAttribution: ravi.shankar at OpenSense Labs commentedI have addressed comments #4 and #5, please review.
Comment #8
longwaveI think we should inline the variable in this test and SaveUploadTest.
Again we can just inline the variable here.
Comment #9
ravi.shankar CreditAttribution: ravi.shankar at OpenSense Labs commentedMade changes as per comment #8, please review.
Comment #10
longwaveThere are more instances of:
I think we should inline all the ones changed in SaveUploadTest in this patch.
Comment #11
mondrakePlease, either leave
$this->assertEqual
, or when converting to$this->assertEquals
, note that the expected and the actual arguments should be swapped.Comment #12
mondrakeIDK, but in a small patch like this, IMHO we should also convert assertText and assertRaw (that are deprecated since D 8.2.0!) to their WebAssert equivalents. The conversion of those will be tough and big, so whatever we can do to anticipate some conversions, will help later. My opinion though: please let's discuss before jumping to code.
Comment #13
longwaveRe #12 I also think doing those conversions here is worthwhile, I guess this is a small enough patch to try it here and see if core committers agree? If we do do this, we should only touch lines that would be touched by the patch anyway, no matter how tempting it is to scope creep into the next line even if it seems trivial.
Comment #14
mondrake+1 for #13!
Comment #15
longwaveAddressed #10-#13. No interdiff as pretty much every line has changed again.
I think I am perhaps taking liberties with this, but it's a good a time as any to do it:
Comment #16
mondrakeI think we can use WebAssert methods here like
elementExists
andelementAttributeContains
verbose
is actually a no-op in PHPUnit, in other issues we just removed calls to itComment #17
Pooja Ganjage CreditAttribution: Pooja Ganjage at Asentech LLC commentedHi,
Creating a patch as suggested in #16 comment.
Please review the patch.
Thanks.
Comment #18
longwave#17 does not apply.
Addressed #16 from #15.
Comment #19
longwaveUploaded the wrong files, let's try again.
Comment #20
mondrakeThank you
Comment #23
catchCommitted/pushed to 9.2.x and cherry-picked to 9.1.x, thanks!