function DisplayPageWebTest::testAdminTheme
Same name in other branches
- 11.x core/modules/views/tests/src/Functional/Plugin/DisplayPageWebTest.php \Drupal\Tests\views\Functional\Plugin\DisplayPageWebTest::testAdminTheme()
Tests the 'use_admin_theme' page display option.
File
-
core/
modules/ views/ tests/ src/ Functional/ Plugin/ DisplayPageWebTest.php, line 153
Class
- DisplayPageWebTest
- Tests the views page display plugin.
Namespace
Drupal\Tests\views\Functional\PluginCode
public function testAdminTheme() : void {
$account = $this->drupalCreateUser([
'view the administration theme',
]);
$this->drupalLogin($account);
// Use distinct default and administrative themes for this test.
/** @var \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler */
$theme_handler = $this->container
->get('theme_handler');
/** @var \Drupal\Core\Extension\ThemeInstallerInterface $theme_installer */
$theme_installer = $this->container
->get('theme_installer');
$theme_installer->install([
'claro',
]);
$this->container
->get('config.factory')
->getEditable('system.theme')
->set('admin', 'claro')
->set('default', 'stable')
->save();
$theme_handler->refreshInfo();
// Check that the page has been served with the default theme.
$this->drupalGet('test_page_display_200');
$this->assertSession()
->responseNotContains('core/themes/claro/css/base/elements.css');
$view = $this->config('views.view.test_page_display');
$view->set('display.page_3.display_options.use_admin_theme', TRUE)
->save();
$this->container
->get('router.builder')
->rebuild();
// Check that the page was served with the administrative theme.
$this->drupalGet('test_page_display_200');
$this->assertSession()
->responseContains('core/themes/claro/css/base/elements.css');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.