public function EntityExtraEventTest::testEntityExtraFieldInfoEventWithSetFunction in Hook Event Dispatcher 3.x
Same name and namespace in other branches
- 8.2 modules/core_event_dispatcher/tests/src/Unit/Entity/EntityExtraEventTest.php \Drupal\Tests\core_event_dispatcher\Unit\Entity\EntityExtraEventTest::testEntityExtraFieldInfoEventWithSetFunction()
Test EntityExtraFieldInfoEvent with set function.
File
- modules/
core_event_dispatcher/ tests/ src/ Unit/ Entity/ EntityExtraEventTest.php, line 82
Class
- EntityExtraEventTest
- Class EntityExtraEventTest.
Namespace
Drupal\Tests\core_event_dispatcher\Unit\EntityCode
public function testEntityExtraFieldInfoEventWithSetFunction() : void {
$fieldInfo = [
'node' => [
'test' => [
'display' => [
'field_test' => [
'test' => 'node',
],
],
],
],
'entity' => [
'test_entity' => [
'form' => [
'field_node' => [
'test' => 'entity',
],
],
],
],
];
$this->manager
->setEventCallbacks([
HookEventDispatcherInterface::ENTITY_EXTRA_FIELD_INFO => static function (EntityExtraFieldInfoEvent $event) use ($fieldInfo) {
$event
->setFieldInfo($fieldInfo);
},
]);
$hookFieldInfoResult = core_event_dispatcher_entity_extra_field_info();
self::assertSame($fieldInfo, $hookFieldInfoResult);
/** @var \Drupal\core_event_dispatcher\Event\Entity\EntityExtraFieldInfoEvent $event */
$event = $this->manager
->getRegisteredEvent(HookEventDispatcherInterface::ENTITY_EXTRA_FIELD_INFO);
self::assertSame($fieldInfo, $event
->getFieldInfo());
}