You are here

public function EntityEventTest::testEntityLoadEvent in Hook Event Dispatcher 3.x

Same name and namespace in other branches
  1. 8.2 modules/core_event_dispatcher/tests/src/Unit/Entity/EntityEventTest.php \Drupal\Tests\core_event_dispatcher\Unit\Entity\EntityEventTest::testEntityLoadEvent()

Test EntityLoadEvent.

File

modules/core_event_dispatcher/tests/src/Unit/Entity/EntityEventTest.php, line 88

Class

EntityEventTest
Class EntityEventTest.

Namespace

Drupal\Tests\core_event_dispatcher\Unit\Entity

Code

public function testEntityLoadEvent() : void {
  $entities = [
    $this
      ->createMock(EntityInterface::class),
    $this
      ->createMock(EntityInterface::class),
    $this
      ->createMock(EntityInterface::class),
  ];
  $entityTypeId = 'test';
  core_event_dispatcher_entity_load($entities, $entityTypeId);

  /** @var \Drupal\core_event_dispatcher\Event\Entity\EntityLoadEvent $event */
  $event = $this->manager
    ->getRegisteredEvent(HookEventDispatcherInterface::ENTITY_LOAD);
  self::assertSame($entities, $event
    ->getEntities());
  self::assertSame($entityTypeId, $event
    ->getEntityTypeId());
}