function BlockTest::testHideBlockTitle
Same name in other branches
- 9 core/modules/block/tests/src/Functional/BlockTest.php \Drupal\Tests\block\Functional\BlockTest::testHideBlockTitle()
- 8.9.x core/modules/block/tests/src/Functional/BlockTest.php \Drupal\Tests\block\Functional\BlockTest::testHideBlockTitle()
- 11.x core/modules/block/tests/src/Functional/BlockTest.php \Drupal\Tests\block\Functional\BlockTest::testHideBlockTitle()
Tests block title display settings.
File
-
core/
modules/ block/ tests/ src/ Functional/ BlockTest.php, line 345
Class
- BlockTest
- Tests basic block functionality.
Namespace
Drupal\Tests\block\FunctionalCode
public function testHideBlockTitle() : void {
$block_name = 'system_powered_by_block';
// Create a random title for the block.
$title = $this->randomMachineName(8);
$id = $this->randomMachineName(8);
// Enable a standard block.
$default_theme = $this->config('system.theme')
->get('default');
$edit = [
'id' => $id,
'region' => 'sidebar_first',
'settings[label]' => $title,
];
$this->drupalGet('admin/structure/block/add/' . $block_name . '/' . $default_theme);
$this->submitForm($edit, 'Save block');
$this->assertSession()
->statusMessageContains('The block configuration has been saved.', 'status');
// Confirm that the block is not displayed by default.
$this->drupalGet('user');
$this->assertSession()
->pageTextNotContains($title);
$edit = [
'settings[label_display]' => TRUE,
];
$this->drupalGet('admin/structure/block/manage/' . $id);
$this->submitForm($edit, 'Save block');
$this->assertSession()
->statusMessageContains('The block configuration has been saved.', 'status');
$this->drupalGet('admin/structure/block/manage/' . $id);
$this->assertSession()
->checkboxChecked('edit-settings-label-display');
// Confirm that the block is displayed when enabled.
$this->drupalGet('user');
$this->assertSession()
->pageTextContains($title);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.