public function ThemeTest::testAdministrationTheme in Drupal 8
Same name and namespace in other branches
- 9 core/modules/system/tests/src/Functional/System/ThemeTest.php \Drupal\Tests\system\Functional\System\ThemeTest::testAdministrationTheme()
Test the administration theme functionality.
File
- core/
modules/ system/ tests/ src/ Functional/ System/ ThemeTest.php, line 285
Class
- ThemeTest
- Tests the theme interface functionality by enabling and switching themes, and using an administration theme.
Namespace
Drupal\Tests\system\Functional\SystemCode
public function testAdministrationTheme() {
$this->container
->get('theme_installer')
->install([
'seven',
]);
// Install an administration theme and show it on the node admin pages.
$edit = [
'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 = [
'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
->assertSession()
->statusCodeEquals(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 = [
'admin_theme' => '',
'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.');
}