function ThemeSuggestionsAlterTest::testTemplateSuggestions

Same name in other branches
  1. 8.9.x core/modules/system/tests/src/Functional/Theme/ThemeSuggestionsAlterTest.php \Drupal\Tests\system\Functional\Theme\ThemeSuggestionsAlterTest::testTemplateSuggestions()
  2. 10 core/modules/system/tests/src/Functional/Theme/ThemeSuggestionsAlterTest.php \Drupal\Tests\system\Functional\Theme\ThemeSuggestionsAlterTest::testTemplateSuggestions()
  3. 11.x core/modules/system/tests/src/Functional/Theme/ThemeSuggestionsAlterTest.php \Drupal\Tests\system\Functional\Theme\ThemeSuggestionsAlterTest::testTemplateSuggestions()

Tests that hooks to provide theme suggestions work.

File

core/modules/system/tests/src/Functional/Theme/ThemeSuggestionsAlterTest.php, line 38

Class

ThemeSuggestionsAlterTest
Tests theme suggestion alter hooks.

Namespace

Drupal\Tests\system\Functional\Theme

Code

public function testTemplateSuggestions() {
    $this->drupalGet('theme-test/suggestion-provided');
    $this->assertSession()
        ->pageTextContains('Template for testing suggestions provided by the module declaring the theme hook.');
    // Install test_theme, it contains a template suggested by theme_test.module
    // in theme_test_theme_suggestions_theme_test_suggestion_provided().
    $this->config('system.theme')
        ->set('default', 'test_theme')
        ->save();
    $this->drupalGet('theme-test/suggestion-provided');
    $this->assertSession()
        ->pageTextContains('Template overridden based on suggestion provided by the module declaring the theme hook.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.