function AssertBlockAppearsTrait::findBlockInstance

Same name and namespace in other branches
  1. 9 core/modules/block/tests/src/Functional/AssertBlockAppearsTrait.php \Drupal\Tests\block\Functional\AssertBlockAppearsTrait::findBlockInstance()
  2. 8.9.x core/modules/block/tests/src/Functional/AssertBlockAppearsTrait.php \Drupal\Tests\block\Functional\AssertBlockAppearsTrait::findBlockInstance()

Find a block instance on the page.

Parameters

\Drupal\block\Entity\Block $block: The block entity to find on the page.

Return value

array The result from the xpath query.

Deprecated

in drupal:9.5.0 and is removed from drupal:11.0.0. There is no replacement.

See also

https://www.drupal.org/node/3293310

File

core/modules/block/tests/src/Functional/AssertBlockAppearsTrait.php, line 50

Class

AssertBlockAppearsTrait
Provides test assertions for testing block appearance.

Namespace

Drupal\Tests\block\Functional

Code

protected function findBlockInstance(Block $block) {
    @trigger_error(__METHOD__ . '() is deprecated in drupal:9.5.0 and is removed from drupal:11.0.0. There is no replacement. See https://www.drupal.org/node/3293310', E_USER_DEPRECATED);
    return $this->xpath('//div[@id = :id]', [
        ':id' => 'block-' . $block->id(),
    ]);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.