public function LibraryInfoAlterEventTest::testLibraryInfoAlterEvent in Hook Event Dispatcher 8
Test the LibraryInfoAlterEventTest.
File
- tests/
src/ Unit/ Theme/ LibraryInfoAlterEventTest.php, line 41
Class
- LibraryInfoAlterEventTest
- Class LibraryInfoAlterEventTest.
Namespace
Drupal\Tests\hook_event_dispatcher\Unit\ThemeCode
public function testLibraryInfoAlterEvent() {
$this->manager
->setEventCallbacks([
HookEventDispatcherInterface::LIBRARY_INFO_ALTER => function (LibraryInfoAlterEvent $event) {
$libraries =& $event
->getLibraries();
$libraries['test_library'] = 'test_altered';
},
]);
$libraries = $expectedLibraries = [
'test_library' => 'test',
];
$extension = 'test_module';
hook_event_dispatcher_library_info_alter($libraries, $extension);
$expectedLibraries['test_library'] = 'test_altered';
self::assertSame($libraries, $expectedLibraries);
/** @var \Drupal\hook_event_dispatcher\Event\Theme\LibraryInfoAlterEvent $event */
$event = $this->manager
->getRegisteredEvent(HookEventDispatcherInterface::LIBRARY_INFO_ALTER);
self::assertSame($libraries, $event
->getLibraries());
self::assertSame($extension, $event
->getExtension());
}