function ThemeTest::testAdministrationTheme in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/src/Tests/System/ThemeTest.php \Drupal\system\Tests\System\ThemeTest::testAdministrationTheme()
Test the administration theme functionality.
File
- core/
modules/ system/ src/ Tests/ System/ ThemeTest.php, line 218 - Contains \Drupal\system\Tests\System\ThemeTest.
Class
- ThemeTest
- Tests the theme interface functionality by enabling and switching themes, and using an administration theme.
Namespace
Drupal\system\Tests\SystemCode
function testAdministrationTheme() {
$this->container
->get('theme_handler')
->install(array(
'seven',
));
// Install an administration theme and show it on the node admin pages.
$edit = array(
'admin_theme' => 'seven',
'use_admin_theme' => TRUE,
);
$this
->drupalPostForm('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
->id());
$this
->assertRaw('core/themes/classy', '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
->id() . '/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(
'use_admin_theme' => FALSE,
);
$this
->drupalPostForm('admin/appearance', $edit, t('Save configuration'));
$this
->drupalGet('admin/config');
$this
->assertRaw('core/themes/seven', 'Administration theme used on an administration page.');
// Ensure that the admin theme is also visible on the 403 page.
$normal_user = $this
->drupalCreateUser([
'view the administration theme',
]);
$this
->drupalLogin($normal_user);
$this
->drupalGet('admin/config');
$this
->assertResponse(403);
$this
->assertRaw('core/themes/seven', 'Administration theme used on an administration page.');
$this
->drupalLogin($this->adminUser);
$this
->drupalGet('node/add');
$this
->assertRaw('core/themes/classy', 'Site default theme used on the add content page.');
// Reset to the default theme settings.
$edit = array(
'admin_theme' => '0',
'use_admin_theme' => FALSE,
);
$this
->drupalPostForm('admin/appearance', $edit, t('Save configuration'));
$this
->drupalGet('admin');
$this
->assertRaw('core/themes/classy', 'Site default theme used on administration page.');
$this
->drupalGet('node/add');
$this
->assertRaw('core/themes/classy', 'Site default theme used on the add content page.');
}