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