class ThemeHookTest
Same name and namespace in other branches
- main core/modules/system/tests/src/Kernel/Theme/ThemeHookTest.php \Drupal\Tests\system\Kernel\Theme\ThemeHookTest
Tests low-level theme functions.
Attributes
#[Group('Theme')]
#[RunTestsInSeparateProcesses]
Hierarchy
- class \Drupal\KernelTests\KernelTestBase implements \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\Tests\DrupalTestCaseTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\PhpUnitCompatibilityTrait, \Prophecy\PhpUnit\ProphecyTrait, \Drupal\TestTools\Extension\DeprecationBridge\ExpectDeprecationTrait, \Drupal\Tests\BrowserHtmlDebugTrait, \Drupal\Tests\HttpKernelUiHelperTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\Tests\system\Kernel\Theme\ThemeHookTest extends \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of ThemeHookTest
File
-
core/
modules/ system/ tests/ src/ Kernel/ Theme/ ThemeHookTest.php, line 15
Namespace
Drupal\Tests\system\Kernel\ThemeView source
class ThemeHookTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
public function setUp() : void {
parent::setUp();
\Drupal::service('theme_installer')->install([
'procedural_hook_theme',
]);
\Drupal::theme()->setActiveTheme(\Drupal::service(ThemeInitializationInterface::class)->initTheme('procedural_hook_theme'));
}
/**
* Tests that procedural hooks are collected and executed.
*/
public function testProceduralHookCollection() : void {
$args = [];
\Drupal::theme()->alter('procedural', $args);
$this->assertEquals([
'Procedural theme hook executed.',
], $args);
}
/**
* Tests that procedural hooks with #[LegacyHook] are properly ignored.
*/
public function testLegacyHookInThemes() : void {
$args = [];
\Drupal::theme()->alter('procedural_legacy', $args);
$this->assertEquals([
'OOP theme hook executed.',
], $args);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.