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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jonathan1055 created an issue. See original summary.

jonathan1055’s picture

Status: Active » Needs review
FileSize
10.68 KB

Here's a patch

jonathan1055’s picture

There is one other place in test code where we use t(' ') so might as well remove that here too,

idebr’s picture

Status: Needs review » Reviewed & tested by the community

Patch applies correctly to 8.x-1.x and replaces all occurrences assertRaw(t())

  • jonathan1055 committed d00c8e1 on 8.x-1.x
    Issue #3031199 by jonathan1055: Replace assertRaw(t()) with assertText()
    
jonathan1055’s picture

Status: Reviewed & tested by the community » Fixed
FileSize
134.82 KB
113.6 KB

Thanks 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:
before fixing assertraw

and after:
after replacing assertraw

Unfortunately, this commit will force a re-roll of patch recently added to #3032131-11: Replace deprecated REQUEST_TIME

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.