function BlockUiTest::testCandidateBlockList

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

Tests the block categories on the listing page.

File

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

Class

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

Namespace

Drupal\Tests\block\Functional

Code

public function testCandidateBlockList() : void {
    $this->drupalGet('admin/structure/block');
    $this->clickLink('Place block');
    $this->assertSession()
        ->elementExists('xpath', '//tr[.//td/div[text()="Display message"] and .//td[text()="Block test"] and .//td//a[contains(@href, "admin/structure/block/add/test_block_instantiation/stark")]]');
    // Trigger the custom category addition in block_test_block_alter().
    $this->container
        ->get('state')
        ->set('block_test_info_alter', TRUE);
    $this->container
        ->get('plugin.manager.block')
        ->clearCachedDefinitions();
    $this->drupalGet('admin/structure/block');
    $this->clickLink('Place block');
    $this->assertSession()
        ->elementExists('xpath', '//tr[.//td/div[text()="Display message"] and .//td[text()="Custom category"] and .//td//a[contains(@href, "admin/structure/block/add/test_block_instantiation/stark")]]');
}

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