function ThemeSuggestionsAlterTest::testGeneralSuggestionsAlter
Same name in other branches
- 9 core/modules/system/tests/src/Functional/Theme/ThemeSuggestionsAlterTest.php \Drupal\Tests\system\Functional\Theme\ThemeSuggestionsAlterTest::testGeneralSuggestionsAlter()
- 8.9.x core/modules/system/tests/src/Functional/Theme/ThemeSuggestionsAlterTest.php \Drupal\Tests\system\Functional\Theme\ThemeSuggestionsAlterTest::testGeneralSuggestionsAlter()
- 11.x core/modules/system/tests/src/Functional/Theme/ThemeSuggestionsAlterTest.php \Drupal\Tests\system\Functional\Theme\ThemeSuggestionsAlterTest::testGeneralSuggestionsAlter()
Tests hook_theme_suggestions_alter().
File
-
core/
modules/ system/ tests/ src/ Functional/ Theme/ ThemeSuggestionsAlterTest.php, line 55
Class
- ThemeSuggestionsAlterTest
- Tests theme suggestion alter hooks.
Namespace
Drupal\Tests\system\Functional\ThemeCode
public function testGeneralSuggestionsAlter() : void {
$this->drupalGet('theme-test/general-suggestion-alter');
$this->assertSession()
->pageTextContains('Original template for testing hook_theme_suggestions_alter().');
$this->assertSession()
->pageTextContains('Hooks: theme_test_theme none');
// Install test_theme and test that themes can alter template suggestions.
$this->config('system.theme')
->set('default', 'test_theme')
->save();
$this->drupalGet('theme-test/general-suggestion-alter');
$this->assertSession()
->pageTextContains('Template overridden based on new theme suggestion provided by the test_theme theme via hook_theme_suggestions_alter().');
$this->assertSession()
->pageTextContains('Hooks: theme_test_theme test_theme_theme_suggestions_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/general-suggestion-alter');
$this->assertSession()
->pageTextContains('Template overridden based on new theme suggestion provided by a module via hook_theme_suggestions_alter().');
$this->assertSession()
->pageTextContains('Hooks: theme_suggestions_test_theme_suggestions_alter test_theme_theme_suggestions_alter');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.