class LibraryInfoAlterEventTest in Hook Event Dispatcher 3.x
Same name and namespace in other branches
- 8.2 modules/core_event_dispatcher/tests/src/Unit/Theme/LibraryInfoAlterEventTest.php \Drupal\Tests\core_event_dispatcher\Unit\Theme\LibraryInfoAlterEventTest
Class LibraryInfoAlterEventTest.
@group hook_event_dispatcher
Hierarchy
- class \Drupal\Tests\core_event_dispatcher\Unit\Theme\LibraryInfoAlterEventTest extends \PHPUnit\Framework\TestCase
Expanded class hierarchy of LibraryInfoAlterEventTest
File
- modules/
core_event_dispatcher/ tests/ src/ Unit/ Theme/ LibraryInfoAlterEventTest.php, line 18
Namespace
Drupal\Tests\core_event_dispatcher\Unit\ThemeView source
class LibraryInfoAlterEventTest extends TestCase {
/**
* The manager.
*
* @var \Drupal\Tests\hook_event_dispatcher\Unit\HookEventDispatcherManagerSpy
*/
private $manager;
/**
* {@inheritdoc}
*/
public function setUp() : void {
$builder = new ContainerBuilder();
$this->manager = new HookEventDispatcherManagerSpy();
$builder
->set('hook_event_dispatcher.manager', $this->manager);
$builder
->compile();
Drupal::setContainer($builder);
}
/**
* Test the LibraryInfoAlterEventTest.
*/
public function testLibraryInfoAlterEvent() : void {
$this->manager
->setEventCallbacks([
HookEventDispatcherInterface::LIBRARY_INFO_ALTER => static function (LibraryInfoAlterEvent $event) {
$libraries =& $event
->getLibraries();
$libraries['test_library'] = 'test_altered';
},
]);
$libraries = $expectedLibraries = [
'test_library' => 'test',
];
$extension = 'test_module';
core_event_dispatcher_library_info_alter($libraries, $extension);
$expectedLibraries['test_library'] = 'test_altered';
self::assertSame($expectedLibraries, $libraries);
/** @var \Drupal\core_event_dispatcher\Event\Theme\LibraryInfoAlterEvent $event */
$event = $this->manager
->getRegisteredEvent(HookEventDispatcherInterface::LIBRARY_INFO_ALTER);
self::assertSame($expectedLibraries, $event
->getLibraries());
self::assertSame($extension, $event
->getExtension());
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
LibraryInfoAlterEventTest:: |
private | property | The manager. | |
LibraryInfoAlterEventTest:: |
public | function | ||
LibraryInfoAlterEventTest:: |
public | function | Test the LibraryInfoAlterEventTest. |