Problem/Motivation

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

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Comments

mondrake created an issue. See original summary.

jungle’s picture

Issue tags: +Deprecated assertions

Adding the "Deprecated assertions" tag to add this into the kanban board https://contribkanban.com/board/Deprecatedassertions

mondrake’s picture

Assigned: Unassigned » mondrake

On this.

mondrake’s picture

Assigned: mondrake » Unassigned
Status: Active » Needs review
StatusFileSize
new4.21 KB

There is only one call to convert. Removed deprecation silencers, added deprecation tests.

jungle’s picture

Status: Needs review » Reviewed & tested by the community

Thanks, @mondrake! LGTM. Queued the testing against 9.0.x

sja112’s picture

Assigned: Unassigned » sja112
Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs reroll

Patch failed to apply on 9.0.x.

Needs re-roll. Working on it.

Thanks.

sja112’s picture

Assigned: sja112 » Unassigned
Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new25.7 KB

Patch for 9.0.x branch.

jungle’s picture

Status: Needs review » Needs work
diff --git a/core/.cspell.json b/core/.cspell.json

Thanks @sja112! A patch entered a wrong issue

jungle’s picture

BTW, an interdiff/a raw-interdiff, is always appreciated

sja112’s picture

Assigned: Unassigned » sja112

@jungle,

Thanks for reporting. My bad didn't check it first before uploading.

sja112’s picture

Assigned: sja112 » Unassigned
Status: Needs work » Needs review
StatusFileSize
new2.01 KB

Status: Needs review » Needs work

The last submitted patch, 11: 3139403-11-9.0.x.patch, failed testing. View results

kishor_kolekar’s picture

Assigned: Unassigned » kishor_kolekar

Working on it

kishor_kolekar’s picture

Status: Needs work » Needs review
StatusFileSize
new3.11 KB
new2.55 KB

please review the patch .

mondrake’s picture

Status: Needs review » Reviewed & tested by the community

@all, please let core committers review and decide if the 9.1 patch is OK, commit it and mark the issue 'Patch to be ported' BEFORE we start working on the backport.

It would be very complicated at this stage to reflect any feedback on 4 separate patches for each currently active branch, so let's get to it one step at the time.

Thanks. #4 was RTBCed and is the one for 9.1.x ATM.

mondrake’s picture

  • xjm committed f73194d on 9.1.x
    Issue #3139403 by mondrake: Replace usages of AssertLegacyTrait::...
xjm’s picture

Version: 9.1.x-dev » 8.8.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)
+++ b/core/modules/system/tests/src/Functional/Pager/PagerTest.php
--- a/core/tests/Drupal/Tests/Core/Assert/AssertLegacyTraitTest.php
@@ -178,6 +178,30 @@ public function testAssertNoCacheTag() {
+  /**
+   * @covers ::assertElementPresent
+   * @expectedDeprecation AssertLegacyTrait::assertElementPresent() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->elementExists() instead. See https://www.drupal.org/node/3129738
+   */
...
+  /**
+   * @covers ::assertElementNotPresent
...
+   */

They're still supposed to have one-line summaries technically, but I don't care enough about that particular docs standard to NW this given the redundancy with the @covers. :)

Confirmed that 9.1.x had just the one usage, and committed #4. Thanks!

PTBP for a backport that does not un-silence the deprecation.

sja112’s picture

Assigned: kishor_kolekar » sja112
sja112’s picture

sja112’s picture

sja112’s picture

Status: Patch (to be ported) » Needs review
StatusFileSize
new2.41 KB
sja112’s picture

Assigned: sja112 » Unassigned
sja112’s picture

StatusFileSize
new2.01 KB

Uploaded incorrect patch. Correcting mistake here.

sja112’s picture

StatusFileSize
new3.84 KB
new1.83 KB
mondrake’s picture

StatusFileSize
new617 bytes

@sja112 thanks - please be aware that the technical deprecation of all these methods is only implemented on 9.1.x. For backporting, it is sufficient to remove the deprecation test, and the hunk that removes the silencer. For the patch at hand, this one line change should be sufficient.

sja112’s picture

Status: Needs review » Reviewed & tested by the community

@mondrake, thanks for bringing this to my notice. I thought the way we handled depreciations in 9.1.x in similar way we will handle on 8.8.x. That's why I updated the AssertLegacyTrait along with AssertLegacyTraitTest in patch #25.

Patch #26 look good to me. Marking RTBC.

xjm’s picture

Title: Replace usages of AssertLegacyTrait::assertElement(Not)Present, that is deprecated » Replace usages of deprecated AssertLegacyTrait::assertElement(Not)Present()

Oops, thought I'd fixed the title before but apparently did not save it. Updating so that the commit message is right at least on the other branches.

Thanks @mondrake for fixing the patch; #26 is indeed what we want for the backports at this point.

Guessing that fail on 9.0.x is random but it's an odd one since it also appears to be a deprecation. Going to wait for the test to finish re-running to be safe.

xjm’s picture

Issue tags: +Needs followup

FWIW I did also just now confirm that there's lots of past instances of:

2x: Passing an escaped locator to the named selector is deprecated as of 1.7 and will be removed in 2.0. Pass the raw value instead.
    2x in EntityQueryAccessTest::testMediaEntityQueryAccess from Drupal\Tests\views\Functional\Entity

...in "xjm's great collection of HEAD failure emails". I'm guessing a random string is mistakenly triggering the error.

xjm’s picture

I even also reported it before.

  • xjm committed 62b5773 on 9.0.x
    Issue #3139403 by sja112, mondrake, xjm: Replace usages of deprecated...

  • xjm committed cde40a2 on 8.9.x
    Issue #3139403 by sja112, mondrake, xjm: Replace usages of deprecated...

  • xjm committed 9f6aa4f on 8.8.x
    Issue #3139403 by sja112, mondrake, xjm: Replace usages of deprecated...
xjm’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: -Needs followup

Committed #26 to 9.0.x, and cherry-picked to 8.9.x and 8.8.x. I also confirmed all three branches had only the one usage. Thanks!

xjm’s picture

Status: Fixed » Closed (fixed)

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