function AssertBlockAppearsTrait::assertBlockAppears

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

Checks to see whether a block appears on the page.

Parameters

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

File

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

Class

AssertBlockAppearsTrait
Provides test assertions for testing block appearance.

Namespace

Drupal\Tests\block\Functional

Code

protected function assertBlockAppears(Block $block) {
  $this->assertSession()
    ->elementExists('xpath', "//div[@id = 'block-{$block->id()}']");
}

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