The assertText() method of class Drupal\Tests\BrowserTestBase has been deprecated. According to \Drupal\FunctionalTests\AssertLegacyTrait.php it should be replaced with $this->assertSession()->pageTextContains()

66 occurrences found
15 files affected

Comments

bajah1701 created an issue. See original summary.

bajah1701’s picture

StatusFileSize
new38.03 KB
bajah1701’s picture

Status: Active » Needs review
akashkumar07’s picture

Assigned: bajah1701 » Unassigned
StatusFileSize
new37.18 KB

I hope, this patch will solve the issue.

Status: Needs review » Needs work

The last submitted patch, 4: 3050086-4.patch, failed testing. View results

jonathan1055’s picture

Hi AkashkumarOSL,
Thanks for re-rolling the patch. Looking at the tests which failed:

  • SchedulerPermissionsTest and SchedulerPastDatesTest both use Html::escape around the text to check for. This may be causing the problem, as it might not be required in the new assert method. At least, that is a good place to start investigating.
  • In SchedulerLightweightCronTest you have a typo, with a double $$
    +    $$this->assertSession()
    
  • Jonathan

shubham.prakash’s picture

Status: Needs work » Needs review
StatusFileSize
new37.05 KB

Fixed the issues suggested in #6

jonathan1055’s picture

Title: Call to deprecated function assertText() » Replace deprecated function assertText()
Issue summary: View changes
Status: Needs review » Needs work

Hi shubham.prakash,
Thanks for the new patch. SchedulerLightweightCronTest now passes because you have removed the double $$. Also SchedulerPermissionsTest and SchedulerPastDatesTest now pass because you have removed the unnecessary Html::escape . So those are both good. There are now two unused use statements which should be removed (see the coding standards output on the test results page)

However, in re-rolling the patch you have introduced new test failures in SchedulerRulesActionsTest because you have removed ->pageTextContains() in four places.

When making an updated patch, have you considered creating an interdiff file? This will show you the changes between two patches and will give you confidence that you have only changed what you intended to change. It is also very helpful for others who are reviewing the patch. The alternative is to do a file-compare on the two patches, which I have just done, to see how they differ.

shubham.prakash’s picture

Status: Needs work » Needs review
StatusFileSize
new37.47 KB
new4.12 KB

Made changes as suggested in #8, also I'll try to upload interdiff whenever possible. Thanks.

jonathan1055’s picture

StatusFileSize
new895 bytes

Thank you, you fixed the coding standard, and the tests pass.

I noticed one assertText that got missed, see interdiff, but I can fix this on commit.

jonathan1055’s picture

The new pageTextContains() only accepts one parameter, the text to search for. Any other parameters are ignored, but it make sense to remove the extra values anyway.

  • jonathan1055 committed c233ac1 on 8.x-1.x
    Issue #3050086 by jonathan1055: Remove second parameter from all...
jonathan1055’s picture

Status: Needs review » Fixed

Thank you all. Committed and fixed.

jonathan1055’s picture

Title: Replace deprecated function assertText() » Replace deprecated function assertText() with pageTextContains()

Status: Fixed » Closed (fixed)

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