function MenuRouterTest::testThemeCallbackHookCustomTheme

Test that the theme callback wins out over hook_custom_theme().

File

drupal/core/modules/system/lib/Drupal/system/Tests/Menu/MenuRouterTest.php, line 268
Definition of Drupal\system\Tests\Menu\MenuRouterTest.

Class

MenuRouterTest
Tests menu router and hook_menu() functionality.

Namespace

Drupal\system\Tests\Menu

Code

function testThemeCallbackHookCustomTheme() {

  // Trigger hook_custom_theme() to dynamically request the Stark theme for
  // the requested page.
  \Drupal::state()
    ->set('menu_test.hook_custom_theme_name', $this->alternate_theme);
  theme_enable(array(
    $this->alternate_theme,
    $this->admin_theme,
  ));

  // The menu "theme callback" should take precedence over a value set in
  // hook_custom_theme().
  $this
    ->drupalGet('menu-test/theme-callback/use-admin-theme');
  $this
    ->assertText('Custom theme: seven. Actual theme: seven.', 'The result of hook_custom_theme() does not override what was set in a theme callback.');
  $this
    ->assertRaw('seven/style.css', "The Seven theme's CSS appears on the page.");
}