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