Problem/Motivation

AssertLegacyTrait::assertTextHelper() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->pageTextContains() or $this->assertSession()->pageTextNotContains() instead. See https://www.drupal.org/node/3129738

We missed to open an issue for this, and also the deprecation message is wrong.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mondrake created an issue. See original summary.

mondrake’s picture

Assigned: mondrake » Unassigned
Status: Active » Needs review
FileSize
5.95 KB

Patch

mondrake’s picture

paulocs’s picture

Hey @mondrake,

Why did you remove 'AssertLegacyTrait::assertText() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->pageTextContains() or $this->assertSession()->pageTextNotContains() instead. See https://www.drupal.org/node/3129738' from the code?

Cheers, Paulo.

mondrake’s picture

@paulocs - re #4 because that deprecation message is triggered currently from assertTextHelper, but it is wrong because it is mistakingly indicating that it's referring to assertText.

So, this removal

+++ b/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php
@@ -126,7 +126,6 @@ public static function getSkippedDeprecations() {
-      'AssertLegacyTrait::assertText() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->pageTextContains() or $this->assertSession()->pageTextNotContains() instead. See https://www.drupal.org/node/3129738',

is actually balanced by the change of the actual deprecation message triggered by assertTextHelper,

+++ b/core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php
@@ -140,7 +152,7 @@ protected function assertNoText($text) {
   protected function assertTextHelper($text, $not_exists = TRUE) {
-    @trigger_error('AssertLegacyTrait::assertText() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->pageTextContains() or $this->assertSession()->pageTextNotContains() instead. See https://www.drupal.org/node/3129738', E_USER_DEPRECATED);
+    @trigger_error('AssertLegacyTrait::assertTextHelper() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->pageTextContains() or $this->assertSession()->pageTextNotContains() instead. See https://www.drupal.org/node/3129738', E_USER_DEPRECATED);
     $args = ['@text' => $text];
longwave’s picture

Status: Needs review » Reviewed & tested by the community

I guess we have to deprecate this properly, I thought nobody would be using it directly but it turns out contrib has a few hits: http://grep.xnddx.ru/search?text=assertTextHelper&filename=

Makes sense to move the code out so only direct callers get the real deprecation.

mondrake’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs reroll
mondrake’s picture

Status: Needs work » Reviewed & tested by the community
Issue tags: -Needs reroll
FileSize
5.94 KB
855 bytes

Reroll, only patch context conflicts to be resolved.

  • catch committed 6be889d on 9.1.x
    Issue #3168946 by mondrake, paulocs, longwave: Replace usages of...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed 6be889d and pushed to 9.1.x. Thanks!

Status: Fixed » Closed (fixed)

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