function BlockUiTest::testContextAwareUnsatisfiedBlocks

Same name in other branches
  1. 9 core/modules/block/tests/src/Functional/BlockUiTest.php \Drupal\Tests\block\Functional\BlockUiTest::testContextAwareUnsatisfiedBlocks()
  2. 10 core/modules/block/tests/src/Functional/BlockUiTest.php \Drupal\Tests\block\Functional\BlockUiTest::testContextAwareUnsatisfiedBlocks()
  3. 11.x core/modules/block/tests/src/Functional/BlockUiTest.php \Drupal\Tests\block\Functional\BlockUiTest::testContextAwareUnsatisfiedBlocks()

Tests the behavior of unsatisfied context-aware blocks.

File

core/modules/block/tests/src/Functional/BlockUiTest.php, line 204

Class

BlockUiTest
Tests that the block configuration UI exists and stores data correctly.

Namespace

Drupal\Tests\block\Functional

Code

public function testContextAwareUnsatisfiedBlocks() {
    $arguments = [
        ':category' => 'Block test',
        ':href' => 'admin/structure/block/add/test_context_aware_unsatisfied/classy',
        ':text' => 'Test context-aware unsatisfied block',
    ];
    $this->drupalGet('admin/structure/block');
    $this->clickLink('Place block');
    $elements = $this->xpath('//tr[.//td/div[text()=:text] and .//td[text()=:category] and .//td//a[contains(@href, :href)]]', $arguments);
    $this->assertTrue(empty($elements), 'The context-aware test block does not appear.');
    $definition = \Drupal::service('plugin.manager.block')->getDefinition('test_context_aware_unsatisfied');
    $this->assertTrue(!empty($definition), 'The context-aware test block does not exist.');
}

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