public function ToolbarAlterEventTest::testToolbarAlterEventBySet in Hook Event Dispatcher 8
Test the ToolbarAlterEvent by reference.
File
- tests/
src/ Unit/ Toolbar/ ToolbarAlterEventTest.php, line 66
Class
- ToolbarAlterEventTest
- Class ToolbarAlterEventTest.
Namespace
Drupal\Tests\hook_event_dispatcher\Unit\ToolbarCode
public function testToolbarAlterEventBySet() {
$newItem = [
'test' => 'item',
];
$this->manager
->setEventCallbacks([
HookEventDispatcherInterface::TOOLBAR_ALTER => function (ToolbarAlterEvent $event) use ($newItem) {
$items = $event
->getItems();
$items += $newItem;
$event
->setItems($items);
},
]);
$items = [
'user' => [],
'manage' => [],
];
$expectedItems = $items + $newItem;
hook_event_dispatcher_toolbar_alter($items);
self::assertSame($expectedItems, $items);
}