function ThemeTest::testSwitchDefaultTheme 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::testSwitchDefaultTheme()
Test switching the default theme.
File
- core/modules/ system/ src/ Tests/ System/ ThemeTest.php, line 277 
- 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 testSwitchDefaultTheme() {
  /** @var \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler */
  $theme_handler = \Drupal::service('theme_handler');
  // First, install Stark and set it as the default theme programmatically.
  $theme_handler
    ->install(array(
    'stark',
  ));
  $theme_handler
    ->setDefault('stark');
  // Install Bartik and set it as the default theme.
  $theme_handler
    ->install(array(
    'bartik',
  ));
  $this
    ->drupalGet('admin/appearance');
  $this
    ->clickLink(t('Set as default'));
  $this
    ->assertEqual($this
    ->config('system.theme')
    ->get('default'), 'bartik');
  // Test the default theme on the secondary links (blocks admin page).
  $this
    ->drupalGet('admin/structure/block');
  $this
    ->assertText('Bartik(' . t('active tab') . ')', 'Default local task on blocks admin page is the default theme.');
  // Switch back to Stark and test again to test that the menu cache is cleared.
  $this
    ->drupalGet('admin/appearance');
  // Stark is the first 'Set as default' link.
  $this
    ->clickLink(t('Set as default'));
  $this
    ->drupalGet('admin/structure/block');
  $this
    ->assertText('Stark(' . t('active tab') . ')', 'Default local task on blocks admin page has changed.');
}