public function ThemeEventTest::testThemeEventWithAddNewThemes in Hook Event Dispatcher 8
ThemeEvent with addNewThemes test.
File
- tests/
src/ Unit/ Theme/ ThemeEventTest.php, line 42
Class
- ThemeEventTest
- Class ThemeEventTest.
Namespace
Drupal\Tests\hook_event_dispatcher\Unit\ThemeCode
public function testThemeEventWithAddNewThemes() {
$newThemes = [
'some_custom__hook_theme' => [
'variables' => [
'custom_variable' => NULL,
],
'path' => 'some/path',
],
];
$this->manager
->setEventCallbacks([
HookEventDispatcherInterface::THEME => function (ThemeEvent $event) use ($newThemes) {
$event
->addNewThemes($newThemes);
},
]);
$existing = [
'existing_theme_hook__with_information' => [
'render element' => [
'#type' => 'date',
'#title' => 'Some date',
'#default_value' => [
'year' => 2020,
'month' => 2,
'day' => 15,
],
],
],
];
$hookNewInformation = hook_event_dispatcher_theme($existing);
/** @var \Drupal\hook_event_dispatcher\Event\Theme\ThemeEvent $event */
$event = $this->manager
->getRegisteredEvent(HookEventDispatcherInterface::THEME);
self::assertSame($existing, $event
->getExisting());
self::assertSame($newThemes, $hookNewInformation);
}