From f73194d0789d1b79a8818fcef08dcc106ece3f6d Mon Sep 17 00:00:00 2001 From: xjm Date: Tue, 26 May 2020 13:27:13 -0500 Subject: [PATCH] Issue #3139403 by mondrake: Replace usages of AssertLegacyTrait::assertElement(Not)Present, that is deprecated --- .../tests/src/Functional/Pager/PagerTest.php | 2 +- .../Core/Assert/AssertLegacyTraitTest.php | 24 +++++++++++++++++++ .../Listeners/DeprecationListenerTrait.php | 2 -- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/core/modules/system/tests/src/Functional/Pager/PagerTest.php b/core/modules/system/tests/src/Functional/Pager/PagerTest.php index 4a6d7d448cb3..c556d03befdb 100644 --- a/core/modules/system/tests/src/Functional/Pager/PagerTest.php +++ b/core/modules/system/tests/src/Functional/Pager/PagerTest.php @@ -75,7 +75,7 @@ class PagerTest extends BrowserTestBase { // Verify the pager does not render on a list without pagination. $this->drupalGet('admin/config/media/image-styles'); - $this->assertElementNotPresent('.pager'); + $this->assertSession()->elementNotExists('css', '.pager'); } /** diff --git a/core/tests/Drupal/Tests/Core/Assert/AssertLegacyTraitTest.php b/core/tests/Drupal/Tests/Core/Assert/AssertLegacyTraitTest.php index 10c61be2fbcb..e34fe8266074 100644 --- a/core/tests/Drupal/Tests/Core/Assert/AssertLegacyTraitTest.php +++ b/core/tests/Drupal/Tests/Core/Assert/AssertLegacyTraitTest.php @@ -178,6 +178,30 @@ class AssertLegacyTraitTest extends UnitTestCase { $this->assertNoCacheTag('some-cache-tag'); } + /** + * @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 + */ + public function testAssertElementPresent() { + $this->webAssert + ->elementExists('css', '.pager') + ->shouldBeCalled(); + + $this->assertElementPresent('.pager'); + } + + /** + * @covers ::assertElementNotPresent + * @expectedDeprecation AssertLegacyTrait::assertElementNotPresent() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->elementNotExists() instead. See https://www.drupal.org/node/3129738 + */ + public function testAssertElementNotPresent() { + $this->webAssert + ->elementNotExists('css', '.pager') + ->shouldBeCalled(); + + $this->assertElementNotPresent('.pager'); + } + /** * Returns a mocked behat session object. * diff --git a/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php b/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php index 42ac2181d45b..3a58e8a4cf56 100644 --- a/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php +++ b/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php @@ -173,8 +173,6 @@ trait DeprecationListenerTrait { 'AssertLegacyTrait::assertIdentical() is deprecated in drupal:8.0.0 and is removed from drupal:10.0.0. Use $this->assertSame() instead. See https://www.drupal.org/node/3129738', 'AssertLegacyTrait::assertNotIdentical() is deprecated in drupal:8.0.0 and is removed from drupal:10.0.0. Use $this->assertNotSame() instead. See https://www.drupal.org/node/3129738', 'AssertLegacyTrait::pass() is deprecated in drupal:8.0.0 and is removed from drupal:10.0.0. PHPUnit interrupts a test as soon as a test assertion fails, so there is usually no need to call this method. If a test\'s logic relies on this method, refactor the test. See https://www.drupal.org/node/3129738', - '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', - 'AssertLegacyTrait::assertElementNotPresent() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->elementNotExists() instead. See https://www.drupal.org/node/3129738', 'AssertLegacyTrait::assertText() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->responseContains() or $this->assertSession()->pageTextContains() instead. See https://www.drupal.org/node/3129738', 'AssertLegacyTrait::assertNoText() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->responseNotContains() or $this->assertSession()->pageTextNotContains() instead. See https://www.drupal.org/node/3129738', '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',