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