public function BlockTest::testHideBlockTitle in Drupal 8
Same name and namespace in other branches
- 9 core/modules/block/tests/src/Functional/BlockTest.php \Drupal\Tests\block\Functional\BlockTest::testHideBlockTitle()
Test block title display settings.
File
- core/
modules/ block/ tests/ src/ Functional/ BlockTest.php, line 294
Class
- BlockTest
- Tests basic block functionality.
Namespace
Drupal\Tests\block\FunctionalCode
public function testHideBlockTitle() {
$block_name = 'system_powered_by_block';
// Create a random title for the block.
$title = $this
->randomMachineName(8);
$id = strtolower($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
->drupalPostForm('admin/structure/block/add/' . $block_name . '/' . $default_theme, $edit, t('Save block'));
$this
->assertText('The block configuration has been saved.', 'Block was saved');
$this
->drupalGet('user');
$this
->assertNoText($title, 'Block title was not displayed by default.');
$edit = [
'settings[label_display]' => TRUE,
];
$this
->drupalPostForm('admin/structure/block/manage/' . $id, $edit, t('Save block'));
$this
->assertText('The block configuration has been saved.', 'Block was saved');
$this
->drupalGet('admin/structure/block/manage/' . $id);
$this
->assertFieldChecked('edit-settings-label-display', 'The display_block option has the correct default value on the configuration form.');
$this
->drupalGet('user');
$this
->assertText($title, 'Block title was displayed when enabled.');
}