Problem/Motivation

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

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.

jungle’s picture

Issue tags: +Deprecated assertions

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

jungle’s picture

Status: Active » Needs review
FileSize
15.42 KB
jungle’s picture

Fixing CS

xjm’s picture

Title: Replace usages of AssertLegacyTrait::buildXPathQuery, that is deprecated » Replace usages of deprecated AssertLegacyTrait::buildXPathQuery()

Status: Needs review » Needs work

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

pavnish’s picture

Assigned: Unassigned » pavnish
mohrerao’s picture

Assigned: pavnish » mohrerao
siddhant.bhosale’s picture

Assigned: mohrerao » siddhant.bhosale
siddhant.bhosale’s picture

Assigned: siddhant.bhosale » Unassigned
Status: Needs work » Needs review
FileSize
12.17 KB

Hi, Please review the Patch.

Status: Needs review » Needs work

The last submitted patch, 10: 3139440-10.patch, failed testing. View results

sharma.amitt16’s picture

I am working on the test case failures.

sharma.amitt16’s picture

Status: Needs work » Needs review
FileSize
12.18 KB

Fix for test failures.

Apologies for the interdiff. generating the interdiff file.

Don't know why but interdiff is giving error on this patch so while I am fixing that on my computer below is the change I made from patch #10

In core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php

-    return $this->assertSession()->buildXPathQuery($xpath, ['value' => $value]);
+    return $this->assertSession()->buildXPathQuery($xpath, [':value' => $value]);
   }
Hardik_Patel_12’s picture

Adding interdiff between patch at #10 and #13. Patch at #13 is looks good to me but it has some additional changes like

--- a/core/modules/views/tests/src/Functional/Handler/FieldWebTest.php
 +++ b/core/modules/views/tests/src/Functional/Handler/FieldWebTest.php
 @@ -47,6 +47,9 @@ class FieldWebTest extends ViewTestBase {
      'views_test_data_name' => 'name',
    ];
- 
+
 +  /**
-+   *
++   * {@inheritdoc}
 +   */
    protected function setUp($import_test_views = TRUE): void {
      parent::setUp($import_test_views);
--- a/core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php
 +++ b/core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php
 @@ -38,6 +38,9 @@ class ExposedFormTest extends ViewTestBase {
     */
    protected $defaultTheme = 'classy';
- 
+
 +  /**
-+   *
++   * {@inheritdoc}
 +   */
    protected function setUp($import_test_views = TRUE): void {
      parent::setUp($import_test_views);
-+   *   The Behat session object;.
++   *   The Behat session object.
-    // Loops trough all the option groups
 +    // Loops trough all the option groups.

other than this patch is looks good me.

durgeshs’s picture

Assigned: Unassigned » durgeshs
durgeshs’s picture

Assigned: durgeshs » Unassigned
Status: Needs review » Reviewed & tested by the community
FileSize
41.44 KB

@Hardik_Patel_12,

I have checked interdiff, which was added by you and checked your comment #14, I think no need to update last patch #13. Because there are removed extra space and added Doc comment, which was empty.

Patch #13 is looks good for me and we can move for RTBC+1.

catch’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceAdminTest.php
@@ -355,7 +355,7 @@ public function testMultipleTargetBundles() {
    *
    * @param string $target_type
-   *   The name of the target type
+   *   The name of the target type.
    * @param string[] $bundles
    *   A list of bundle IDs. Defaults to [].

We should remove the unrelated changes from this patch and handle them in a separate issue.

Also, we should add a trigger_error() to the deprecated buildXPathQuery() methods, either here or in a follow-up:

  protected function buildXPathQuery($xpath, array $args = []) {
    return $this->assertSession()->buildXPathQuery($xpath, $args);
  }
mondrake’s picture

#17 it's properly deprecated with @trigger_error in 9.1.x AFAICS:

  protected function buildXPathQuery($xpath, array $args = []) {
    @trigger_error('AssertLegacyTrait::buildXPathQuery() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->buildXPathQuery() instead. See https://www.drupal.org/node/3129738', E_USER_DEPRECATED);
    return $this->assertSession()->buildXPathQuery($xpath, $args);
  }

or I am missing something?

Hardik_Patel_12’s picture

Assigned: Unassigned » Hardik_Patel_12

Working on it.

Hardik_Patel_12’s picture

FileSize
10.31 KB

Patch at #13 is now failed to apply , re-rolling the patch and removing unrelated changes and deprecated with @trigger_error is already there. Kindly review a new patch.

Hardik_Patel_12’s picture

Assigned: Hardik_Patel_12 » Unassigned
Status: Needs work » Needs review
catch’s picture

@mondrake no I think it was me who was missing something...

jungle’s picture

Assigned: Unassigned » jungle
Status: Needs review » Needs work
FileSize
2.08 KB
11.48 KB
  1. +++ b/core/modules/views/tests/src/Functional/Handler/FieldWebTest.php
    @@ -47,6 +47,9 @@ class FieldWebTest extends ViewTestBase {
    +  /**
    +   * ¶
    +   */
    

    {@inheritdoc}

  2. +++ b/core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php
    @@ -38,6 +38,9 @@ class ExposedFormTest extends ViewTestBase {
    +  /**
    +   * ¶
    +   */
    

    Same

The re-roll in #20 does not look right, Did again based on #13.

jungle’s picture

  1. +++ b/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php
    @@ -817,4 +817,14 @@ public function testDeprecationHeaders() {
    +  /**
    +   * Tests legacy buildXPathQuery().
    +   *
    +   * @group legacy
    +   * @expectedDeprecation AssertLegacyTrait::buildXPathQuery() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->buildXPathQuery() instead. See https://www.drupal.org/node/3129738
    +   */
    +  public function testBuildXPathQuery() {
    +    $this->buildXPathQuery('\\html');
    +  }
    +
    

    The test was lost in the middle.

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

    Lost the removal in the middle.

  3. A lot of changes unexpected / out of scope
jungle’s picture

Assigned: jungle » Unassigned
Status: Needs work » Needs review
FileSize
6.31 KB
11.11 KB

Addressing #24

mondrake’s picture

Status: Needs review » Reviewed & tested by the community

Thanks

alexpott’s picture

Title: Replace usages of deprecated AssertLegacyTrait::buildXPathQuery() » [backport] Replace usages of deprecated AssertLegacyTrait::buildXPathQuery()
Version: 9.1.x-dev » 9.0.x-dev
Status: Reviewed & tested by the community » Needs work

Committed c114930 and pushed to 9.1.x. Thanks!

I't be good to have a version of this to backport to 9.0.x and 8.9.x to keep the tests aligned. Minus the change to the skipped deprecations and the test of deprecation message.

  • alexpott committed c114930 on 9.1.x
    Issue #3139440 by jungle, Hardik_Patel_12, siddhant.bhosale, sharma....
pavnish’s picture

Assigned: Unassigned » pavnish

@alexpott I am working on to backport to 9.0.x and 8.9.x.I will upload the patch soon after test.

pavnish’s picture

Assigned: pavnish » Unassigned
Status: Needs work » Needs review
FileSize
11.15 KB
11.88 KB

@alexpott patch has been re-rolled for 8.9.x and 9.0.x .

The last submitted patch, 30: 3139440-9.0.x-30.patch, failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 30: 3139440-8.9.x-30.patch, failed testing. View results

mondrake’s picture

+++ b/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php
@@ -260,6 +260,16 @@ public function testGetRawContent() {
+  /**
+   * Tests legacy buildXPathQuery().
+   *
+   * @group legacy
+   * @expectedDeprecation AssertLegacyTrait::buildXPathQuery() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->buildXPathQuery() instead. See https://www.drupal.org/node/3129738
+   */
+  public function testBuildXPathQuery() {
+    $this->buildXPathQuery('\\html');
+  }
+

This should be removed.

pavnish’s picture

Status: Needs work » Needs review
FileSize
10.7 KB
8.57 KB

@mondrake point #33 has been noticed for re-rolled patch. I have removed testBuildXPathQuery() from these patches.
Please review these patches.
Could you please conform we need to be remove this in 9.1.x

Thanks
pavnish

pavnish’s picture

mondrake’s picture

+++ b/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php
@@ -146,6 +146,8 @@ public static function getSkippedDeprecations() {
+      'AssertLegacyTrait::buildXPathQuery() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->buildXPathQuery() instead. See https://www.drupal.org/node/3129738',
+      'AssertLegacyTrait::getRawContent() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->getSession()->getPage()->getContent() instead. See https://www.drupal.org/node/3129738'

This needs to be removed from the 8.9.x patch.

@pavnish the entries in the DeprecationListenerTrait and the deprecation tests were only added in 9.1.x, since it's in that branch that we are finally throwing errors in case the methods are used, not earlier. So when backporting any of these replacement patches, we need to skip any code that has to do with the deprecations silencing and any deprecation test (taht would fail).

mondrake’s picture

Status: Needs review » Needs work
pavnish’s picture

Status: Needs work » Needs review
FileSize
9.29 KB
1.2 KB

@mondrake thanks for the review.
I have changed the patch as suggested by you could you please review.
Thanks for the help :).

mondrake’s picture

Status: Needs review » Reviewed & tested by the community

Looks good, thanks.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 38: 3139440-8.9.x-38.patch, failed testing. View results

pavnish’s picture

Status: Needs work » Needs review

@mondrake It was strange that the Drupal CI failed the patch first time. After that i again schedule for the retest then it's showing pass :)
Could you please review again and move this to expected state.

mondrake’s picture

Status: Needs review » Reviewed & tested by the community

Yeah, we came across a so called 'random test failure'.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 38: 3139440-8.9.x-38.patch, failed testing. View results

mondrake’s picture

Version: 9.0.x-dev » 9.1.x-dev
Status: Needs work » Fixed

Marking fixed on the basis of #3027952-54: [Plan] Remove the usage of deprecated methods in tests. Please open a separate issue for backport.

mondrake’s picture

Title: [backport] Replace usages of deprecated AssertLegacyTrait::buildXPathQuery() » Replace usages of deprecated AssertLegacyTrait::buildXPathQuery()

Status: Fixed » Closed (fixed)

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