diff --git a/core/modules/block/tests/src/Functional/AssertBlockAppearsTrait.php b/core/modules/block/tests/src/Functional/AssertBlockAppearsTrait.php new file mode 100644 index 0000000..17244ff --- /dev/null +++ b/core/modules/block/tests/src/Functional/AssertBlockAppearsTrait.php @@ -0,0 +1,50 @@ +findBlockInstance($block); + $this->assertTrue(!empty($result), new FormattableMarkup('Ensure the block @id appears on the page', ['@id' => $block->id()])); + } + + /** + * Checks to see whether a block does not appears on the page. + * + * @param \Drupal\block\Entity\Block $block + * The block entity to find on the page. + */ + protected function assertNoBlockAppears(Block $block) { + $result = $this->findBlockInstance($block); + $this->assertFalse(!empty($result), new FormattableMarkup('Ensure the block @id does not appear on the page', ['@id' => $block->id()])); + } + + /** + * Find a block instance on the page. + * + * @param \Drupal\block\Entity\Block $block + * The block entity to find on the page. + * + * @return array + * The result from the xpath query. + */ + protected function findBlockInstance(Block $block) { + return $this->xpath('//div[@id = :id]', [':id' => 'block-' . $block->id()]); + } + +} diff --git a/core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php b/core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php index d31eaf9..e39f652 100644 --- a/core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php +++ b/core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php @@ -8,6 +8,7 @@ use Drupal\Core\Url; use Drupal\shortcut\Entity\Shortcut; use Drupal\shortcut\Entity\ShortcutSet; +use Drupal\Tests\block\Functional\AssertBlockAppearsTrait; use Drupal\views\Entity\View; /** @@ -17,6 +18,8 @@ */ class ShortcutLinksTest extends ShortcutTestBase { + use AssertBlockAppearsTrait; + /** * Modules to enable. * diff --git a/core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php b/core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php index 4bcd1a4..d11ef76 100644 --- a/core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php +++ b/core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php @@ -4,7 +4,6 @@ use Behat\Mink\Exception\ExpectationException; use Behat\Mink\Selector\Xpath\Escaper; -use Drupal\block\Entity\Block; use Drupal\Component\Render\FormattableMarkup; use Drupal\Component\Utility\Xss; use Drupal\KernelTests\AssertLegacyTrait as BaseAssertLegacyTrait; @@ -813,52 +812,4 @@ protected function getRawContent() { return $this->getSession()->getPage()->getContent(); } - /** - * Checks to see whether a block appears on the page. - * - * @param \Drupal\block\Entity\Block $block - * The block entity to find on the page. - * - * @deprecated Scheduled for removal in Drupal 9.0.0. - * Use $this->xpath() instead and assert that the result is not empty. - */ - protected function assertBlockAppears(Block $block) { - @trigger_error('AssertLegacyTrait::assertBlockAppears() is scheduled for removal in Drupal 9.0.0. Use $this->xpath() instead and assert that the result is not empty.', E_USER_DEPRECATED); - $result = $this->findBlockInstance($block); - $this->assertTrue(!empty($result), format_string('Ensure the block @id appears on the page', ['@id' => $block->id()])); - } - - /** - * Checks to see whether a block does not appears on the page. - * - * @param \Drupal\block\Entity\Block $block - * The block entity to find on the page. - * - * @deprecated Scheduled for removal in Drupal 9.0.0. - * Use $this->xpath() instead and assert that the result is empty. - */ - protected function assertNoBlockAppears(Block $block) { - @trigger_error('AssertLegacyTrait::assertNoBlockAppears() is scheduled for removal in Drupal 9.0.0. Use $this->xpath() instead and assert that the result is empty.', E_USER_DEPRECATED); - $result = $this->findBlockInstance($block); - $this->assertFalse(!empty($result), format_string('Ensure the block @id does not appear on the page', ['@id' => $block->id()])); - } - - /** - * Find a block instance on the page. - * - * @param \Drupal\block\Entity\Block $block - * The block entity to find on the page. - * - * @return array - * The result from the xpath query. - * - * @deprecated Scheduled for removal in Drupal 9.0.0. - * Use $this->xpath('//div[@id = :id]', [':id' => 'block-' . $block->id()]) - * instead. - */ - protected function findBlockInstance(Block $block) { - @trigger_error('AssertLegacyTrait::findBlockInstance() is scheduled for removal in Drupal 9.0.0. Use $this->xpath(\'//div[@id = :id]\', [\':id\' => \'block-\' . $block->id()]) instead.', E_USER_DEPRECATED); - return $this->xpath('//div[@id = :id]', [':id' => 'block-' . $block->id()]); - } - }