public function ThemeRegistryAlterEventTest::testThemeRegistryAlterEventWithThemeAlter in Hook Event Dispatcher 8
ThemeRegistryAlterEvent with theme implementation alter test.
File
- tests/
src/ Unit/ Theme/ ThemeRegistryAlterEventTest.php, line 42
Class
- ThemeRegistryAlterEventTest
- Class ThemeRegistryAlterEventTest.
Namespace
Drupal\Tests\hook_event_dispatcher\Unit\ThemeCode
public function testThemeRegistryAlterEventWithThemeAlter() {
$themeRegistry = $expected = [
'existing_theme_hook__with_information' => [
'variables' => [
'variable1' => NULL,
'variable2' => FALSE,
'variable3' => [],
],
'type' => 'base_theme_engine',
'template' => 'existing-theme-hook--with-information',
],
];
$this->manager
->setEventCallbacks([
HookEventDispatcherInterface::THEME_REGISTRY_ALTER => function (ThemeRegistryAlterEvent $event) {
$themeRegistry =& $event
->getThemeRegistry();
$themeRegistry['existing_theme_hook__with_information']['variables']['variable2'] = TRUE;
},
]);
hook_event_dispatcher_theme_registry_alter($themeRegistry);
$expected['existing_theme_hook__with_information']['variables']['variable2'] = TRUE;
self::assertSame($expected, $themeRegistry);
/** @var \Drupal\hook_event_dispatcher\Event\Theme\ThemeRegistryAlterEvent $event */
$event = $this->manager
->getRegisteredEvent(HookEventDispatcherInterface::THEME_REGISTRY_ALTER);
self::assertSame($expected, $event
->getThemeRegistry());
}