function ThemeTest::testAdministrationTheme

Test the administration theme functionality.

File

drupal/core/modules/system/lib/Drupal/system/Tests/System/ThemeTest.php, line 173
Definition of Drupal\system\Tests\System\ThemeTest.

Class

ThemeTest
Tests the theme interface functionality.

Namespace

Drupal\system\Tests\System

Code

function testAdministrationTheme() {
  theme_enable(array(
    'seven',
  ));

  // Enable an administration theme and show it on the node admin pages.
  $edit = array(
    'admin_theme' => 'seven',
    'node_admin_theme' => TRUE,
  );
  $this
    ->drupalPost('admin/appearance', $edit, t('Save configuration'));
  $this
    ->drupalGet('admin/config');
  $this
    ->assertRaw('core/themes/seven', 'Administration theme used on an administration page.');
  $this
    ->drupalGet('node/' . $this->node->nid);
  $this
    ->assertRaw('core/themes/stark', 'Site default theme used on node page.');
  $this
    ->drupalGet('node/add');
  $this
    ->assertRaw('core/themes/seven', 'Administration theme used on the add content page.');
  $this
    ->drupalGet('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
    ->drupalPost('admin/appearance', $edit, t('Save configuration'));
  $this
    ->drupalGet('admin/config');
  $this
    ->assertRaw('core/themes/seven', 'Administration theme used on an administration page.');
  $this
    ->drupalGet('node/add');
  $this
    ->assertRaw('core/themes/stark', 'Site default theme used on the add content page.');

  // Reset to the default theme settings.
  config('system.theme')
    ->set('default', 'bartik')
    ->save();
  $edit = array(
    'admin_theme' => '0',
    'node_admin_theme' => FALSE,
  );
  $this
    ->drupalPost('admin/appearance', $edit, t('Save configuration'));
  $this
    ->drupalGet('admin');
  $this
    ->assertRaw('core/themes/bartik', 'Site default theme used on administration page.');
  $this
    ->drupalGet('node/add');
  $this
    ->assertRaw('core/themes/bartik', 'Site default theme used on the add content page.');
}