You are here

function ThemeSuggestionsAlterTest::testThemeFunctionSuggestionsAlter in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Theme/ThemeSuggestionsAlterTest.php \Drupal\system\Tests\Theme\ThemeSuggestionsAlterTest::testThemeFunctionSuggestionsAlter()

Tests that theme suggestion alter hooks work for theme functions.

File

core/modules/system/src/Tests/Theme/ThemeSuggestionsAlterTest.php, line 121
Contains \Drupal\system\Tests\Theme\ThemeSuggestionsAlterTest.

Class

ThemeSuggestionsAlterTest
Tests theme suggestion alter hooks.

Namespace

Drupal\system\Tests\Theme

Code

function testThemeFunctionSuggestionsAlter() {
  $this
    ->drupalGet('theme-test/function-suggestion-alter');
  $this
    ->assertText('Original theme function.');

  // Install test_theme and test that themes can alter theme suggestions.
  $this
    ->config('system.theme')
    ->set('default', 'test_theme')
    ->save();
  $this
    ->drupalGet('theme-test/function-suggestion-alter');
  $this
    ->assertText('Theme function overridden based on new theme suggestion provided by the test_theme theme.');

  // Enable the theme_suggestions_test module to test modules implementing
  // suggestions alter hooks.
  \Drupal::service('module_installer')
    ->install(array(
    'theme_suggestions_test',
  ));
  $this
    ->resetAll();
  $this
    ->drupalGet('theme-test/function-suggestion-alter');
  $this
    ->assertText('Theme function overridden based on new theme suggestion provided by a module.');
}