public function BlockUiTest::testCandidateBlockList in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/block/src/Tests/BlockUiTest.php \Drupal\block\Tests\BlockUiTest::testCandidateBlockList()
Tests the block categories on the listing page.
File
- core/
modules/ block/ src/ Tests/ BlockUiTest.php, line 170 - Contains \Drupal\block\Tests\BlockUiTest.
Class
- BlockUiTest
- Tests that the block configuration UI exists and stores data correctly.
Namespace
Drupal\block\TestsCode
public function testCandidateBlockList() {
$arguments = array(
':title' => 'Display message',
':category' => 'Block test',
':href' => 'admin/structure/block/add/test_block_instantiation/classy',
);
$pattern = '//tr[.//td/div[text()=:title] and .//td[text()=:category] and .//td//a[contains(@href, :href)]]';
$this
->drupalGet('admin/structure/block');
$this
->clickLinkPartialName('Place block');
$elements = $this
->xpath($pattern, $arguments);
$this
->assertTrue(!empty($elements), 'The test block appears in the category for its module.');
// 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
->clickLinkPartialName('Place block');
$arguments[':category'] = 'Custom category';
$elements = $this
->xpath($pattern, $arguments);
$this
->assertTrue(!empty($elements), 'The test block appears in a custom category controlled by block_test_block_alter().');
}