public function ThemeSuggestionsAlterTest::testTemplateSuggestionsAlter in Drupal 10
Same name and namespace in other branches
- 8 core/modules/system/tests/src/Functional/Theme/ThemeSuggestionsAlterTest.php \Drupal\Tests\system\Functional\Theme\ThemeSuggestionsAlterTest::testTemplateSuggestionsAlter()
- 9 core/modules/system/tests/src/Functional/Theme/ThemeSuggestionsAlterTest.php \Drupal\Tests\system\Functional\Theme\ThemeSuggestionsAlterTest::testTemplateSuggestionsAlter()
Tests that theme suggestion alter hooks work for templates.
File
- core/
modules/ system/ tests/ src/ Functional/ Theme/ ThemeSuggestionsAlterTest.php, line 74
Class
- ThemeSuggestionsAlterTest
- Tests theme suggestion alter hooks.
Namespace
Drupal\Tests\system\Functional\ThemeCode
public function testTemplateSuggestionsAlter() {
$this
->drupalGet('theme-test/suggestion-alter');
$this
->assertSession()
->pageTextContains('Original template for testing hook_theme_suggestions_HOOK_alter().');
// Install test_theme and test that themes can alter template suggestions.
$this
->config('system.theme')
->set('default', 'test_theme')
->save();
$this
->drupalGet('theme-test/suggestion-alter');
$this
->assertSession()
->pageTextContains('Template overridden based on new theme suggestion provided by the test_theme theme via hook_theme_suggestions_HOOK_alter().');
// Enable the theme_suggestions_test module to test modules implementing
// suggestions alter hooks.
\Drupal::service('module_installer')
->install([
'theme_suggestions_test',
]);
$this
->resetAll();
$this
->drupalGet('theme-test/suggestion-alter');
$this
->assertSession()
->pageTextContains('Template overridden based on new theme suggestion provided by a module via hook_theme_suggestions_HOOK_alter().');
}