public function EntityBaseFieldInfoAlterEventTest::testEntityBaseFieldInfoAlterEvent in Hook Event Dispatcher 8
Test the EntityBaseFieldInfoAlterEvent.
File
- tests/
src/ Unit/ EntityType/ EntityBaseFieldInfoAlterEventTest.php, line 42
Class
- EntityBaseFieldInfoAlterEventTest
- Class EntityBaseFieldInfoAlterEventTest.
Namespace
Drupal\Tests\hook_event_dispatcher\Unit\EntityTypeCode
public function testEntityBaseFieldInfoAlterEvent() {
$this->manager
->setEventCallbacks([
HookEventDispatcherInterface::ENTITY_BASE_FIELD_INFO_ALTER => function (EntityBaseFieldInfoAlterEvent $event) {
$fields =& $event
->getFields();
$fields['field_test'] = 'test_altered';
},
]);
$fields = $expectedFields = [
'field_test' => 'test',
];
$entityType = $this
->createMock(EntityTypeInterface::class);
hook_event_dispatcher_entity_base_field_info_alter($fields, $entityType);
$expectedFields['field_test'] = 'test_altered';
self::assertEquals($fields, $expectedFields);
/** @var \Drupal\hook_event_dispatcher\Event\EntityType\EntityBaseFieldInfoAlterEvent $event */
$event = $this->manager
->getRegisteredEvent(HookEventDispatcherInterface::ENTITY_BASE_FIELD_INFO_ALTER);
self::assertEquals($entityType, $event
->getEntityType());
}