You are here

function BlockTest::testHideBlockTitle in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/block/src/Tests/BlockTest.php \Drupal\block\Tests\BlockTest::testHideBlockTitle()

Test block title display settings.

File

core/modules/block/src/Tests/BlockTest.php, line 242
Contains \Drupal\block\Tests\BlockTest.

Class

BlockTest
Tests basic block functionality.

Namespace

Drupal\block\Tests

Code

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 = array(
    '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
    ->assertText($title, 'Block title was displayed by default.');
  $edit = array(
    'settings[label_display]' => FALSE,
  );
  $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
    ->assertNoFieldChecked('edit-settings-label-display', 'The display_block option has the correct default value on the configuration form.');
  $this
    ->drupalGet('user');
  $this
    ->assertNoText($title, 'Block title was not displayed when hidden.');
}