Problem/Motivation
AssertLegacyTrait::assertTitle is deprecated and will be removed in Drupal 10.
There is a total of 17 occurrences which needs to be replaced.
Steps to reproduce
Proposed resolution
Replace usages with $this->assertSession()-> titleEquals() .
A big number of the assertions passes TranslatableMarkup to AssertLegacyTrait::assertTitle which casts it as a string, something that :: titleEquals() does not do. So we need to either cast it ourself before we pass it. Or just pass the expected title directly, removing the call to t().
Before:
$this->assertTitle('Translation | Drupal');
After:
$this->assertSession()->titleEquals('Translation | Drupal');
Remaining tasks
User interface changes
API changes
Data model changes
Comments
Comment #2
larisse commentedHi! Here's a patch to fix this deprecated notice.
Comment #4
marcusml commentedWow thanks! That was fast!
There's a bunch of occurrences like this where we need to remove TranslatableMarkup and just pass the title directly:
Like this:
Or alternativly cast the TranslatableMarkup to a string.
Not sure what's the preferred approach... looking at core I can't fint any examples of passing using
t()in assertions like this. But maybe there's a case for it here?Comment #5
larisse commentedI never saw any example of passing t(), so what do you prefer? Can I remove it? I can create a new patch.
Comment #6
marcusml commentedI'd remove the use of
t()from the simple occurrences (like the example in #4) and cast the ones that uses it to format the string.Like this one for example:
Comment #7
larisse commentedA new patch.
Comment #8
marcusml commentedThanks again larisse! I've gone through the changes and it all looks good to me. I've pulled the changes down locally and can verify that all
assertTitlecalls has been replaced.Comment #9
berdirThis needs a reroll. Per my recommendation in the main meta issue, I recommend to not work on too many of these in parallel as you'll likely cause extra work as they are quite likely to conflict.
Comment #10
marcusml commentedHere's a reroll. I checked and this shouldn't have any conflicts with the rerolled patch from #3273368: assertFieldByName and assertNoFieldByName is deprecated and will be removed in Drupal 10.
Comment #11
elberI will review it.
Comment #12
elberHi I applied and tested the patch #10, I saw that all changes required on issue summary were corrected. And then I will to move issue status to RTBC.
Comment #14
berdirYes, looks good to me as well.