When testing locally or on Travis, tests with AssertRaw(t(' '))
fail with the following error:
Object of class Drupal\Core\StringTranslation\TranslatableMarkup could not be converted to int
The same happens with AssertNoRaw(t(' '))
. See #2948700: Casting $text value to string in responseContains/responseNotContains methods for the details.
The solution is to use AssertText()
and AssertNoText()
. This is also a good thing to do, because we should not be using any t(' ') calls in tests anyway.
The tests do not fail on d.o. testbot because the parameter is cast as a string in legacy webAssert, hiding the potential faults caused by changes in a newer Mink release.
Comment | File | Size | Author |
---|---|---|---|
#3 | 3031199-3.change_assertRaw_to_assertText.patch | 12.46 KB | jonathan1055 |
|
Comments
Comment #2
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedHere's a patch
Comment #3
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedThere is one other place in test code where we use
t(' ')
so might as well remove that here too,Comment #4
idebr CreditAttribution: idebr at ezCompany commentedPatch applies correctly to 8.x-1.x and replaces all occurrences
assertRaw(t())
Comment #6
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedThanks for the review and the RTBC.
For the record, before this fix the tests failed when I run phpunit locally. Here is the 'before' result running the four tests:
and after:
Unfortunately, this commit will force a re-roll of patch recently added to #3032131-11: Replace deprecated REQUEST_TIME