1 system.test SystemBlockTestCase::testSystemBlocks()

Test displaying and hiding the powered-by and help blocks.

File

core/modules/system/tests/system.test, line 1640
Tests for system.module.

Class

SystemBlockTestCase

Code

function testSystemBlocks() {
  // The powered-by block is enabled by default. Confirm that the block is
  // being displayed.
  $this->backdropGet('node');
  $this->assertRaw('block-system-powered-by', 'Block successfully being displayed on the page.');

  // Configure the header block in various combinations.
  $layout = layout_load('default');
  // Assume that the header block is the first block in the default layout.
  $header_uuid = reset($layout->positions['header']);
  $header_block = $layout->content[$header_uuid];

  // Set the header menu to use a different menu.
  $header_block->settings['block_settings']['menu'] = 'management';

  // Hide the logo (showing the logo tested by the logo test already).
  $header_block->settings['block_settings']['logo'] = 0;

  // Save the layout containing the block.
  $layout->save();

  // Set a logo.
  $edit = array(
    'site_logo_theme' => FALSE,
    'site_logo_path' => $GLOBALS['base_url'] . '/core/misc/feed.png',
  );
  $this->backdropPost('admin/config/system/site-information', $edit, t('Save configuration'));

  $this->backdropGet('<front>');

  $elements = $this->xpath('//*[contains(@class, :block)]//*[@class="site-name"]', array(
    ':block' => 'block-system-header',
  ));
  $this->assert(count($elements) === 1, 'Site title found.');

  $elements = $this->xpath('//*[contains(@class, :block)]//a[@class="logo"]', array(
    ':block' => 'block-system-header',
  ));
  $this->assert(count($elements) === 0, 'Site logo hidden in header block.');

  $elements = $this->xpath('//*[contains(@class, :block)]//*[@class="header-menu"]//a[@href=:href]', array(
    ':block' => 'block-system-header',
    ':href' => url('admin'),
  ));
  $this->assert(count($elements) === 1, 'Management menu is set as the header.');
}