1 system.test SystemThemeFunctionalTest::testAdministrationTheme()

Test the administration theme functionality.

File

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

Class

SystemThemeFunctionalTest
Tests for the theme interface functionality.

Code

function testAdministrationTheme() {
  theme_enable(array('stark'));
  config_set('system.core', 'theme_default', 'stark');
  // Enable an administration theme and show it on the node admin pages.
  $edit = array(
    'admin_theme' => 'seven',
    'node_admin_theme' => TRUE,
  );
  $this->backdropPost('admin/appearance', $edit, t('Save configuration'));

  $this->backdropGet('admin/config');
  $this->assertRaw('core/themes/seven', 'Administration theme used on an administration page.');

  $this->backdropGet('node/' . $this->node->nid);
  $this->assertRaw('core/themes/stark', 'Site default theme used on node page.');

  $this->backdropGet('node/add');
  $this->assertRaw('core/themes/seven', 'Administration theme used on the add content page.');

  $this->backdropGet('node/' . $this->node->nid . '/edit');
  $this->assertRaw('core/themes/seven', 'Administration theme used on the edit content page.');

  // Disable the admin theme on the node admin pages.
  $edit = array(
    'node_admin_theme' => FALSE,
  );
  $this->backdropPost('admin/appearance', $edit, t('Save configuration'));

  $this->backdropGet('admin/config');
  $this->assertRaw('core/themes/seven', 'Administration theme used on an administration page.');

  $this->backdropGet('node/add');
  $this->assertRaw('core/themes/stark', 'Site default theme used on the add content page.');

  // Reset to the default theme settings.
  config_set('system.core', 'theme_default', 'basis');
  $edit = array(
    'admin_theme' => '0',
    'node_admin_theme' => FALSE,
  );
  $this->backdropPost('admin/appearance', $edit, t('Save configuration'));

  $this->backdropGet('admin');
  $this->assertRaw('core/themes/basis', 'Site default theme used on administration page.');

  $this->backdropGet('node/add');
  $this->assertRaw('core/themes/basis', 'Site default theme used on the add content page.');

  // Check that Stark does not show up on the Appearance page.
  $this->backdropGet('admin/appearance');
  $this->assertNoText('Stark', 'Stark theme not shown on appearance page.');

  // Turn on the theme test module, which makes Stark unhidden.
  module_enable(array('theme_test'));
  $this->backdropGet('admin/appearance');
  $this->assertText('Stark', 'Stark theme now shown when hook_system_info_alter() unhides the theme.');
}