function BlockTest::testHideBlockTitle

Test block title display settings.

File

drupal/core/modules/block/lib/Drupal/block/Tests/BlockTest.php, line 143
Contains \Drupal\block\Tests\BlockTest.

Class

BlockTest
Provides testing for basic block module functionality.

Namespace

Drupal\block\Tests

Code

function testHideBlockTitle() {
  $block_name = 'system_powered_by_block';

  // Create a random title for the block.
  $title = $this
    ->randomName(8);
  $machine_name = strtolower($this
    ->randomName(8));

  // Enable a standard block.
  $default_theme = variable_get('theme_default', 'stark');
  $edit = array(
    'machine_name' => $machine_name,
    'region' => 'sidebar_first',
    'settings[label]' => $title,
  );
  $this
    ->drupalPost('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
    ->drupalPost('admin/structure/block/manage/' . $default_theme . '.' . $machine_name . '/configure', $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 when hidden.');
}