You are here

public function EntityEventTest::testEntityUpdateEvent 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::testEntityUpdateEvent()

Test EntityUpdateEvent.

File

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

Class

EntityEventTest
Class EntityEventTest.

Namespace

Drupal\Tests\core_event_dispatcher\Unit\Entity

Code

public function testEntityUpdateEvent() : void {
  $entity = $this
    ->createMock(EntityInterface::class);
  $originalEntity = $this
    ->createMock(EntityInterface::class);
  $entity->original = $originalEntity;
  core_event_dispatcher_entity_update($entity);

  /** @var \Drupal\core_event_dispatcher\Event\Entity\EntityUpdateEvent $event */
  $event = $this->manager
    ->getRegisteredEvent(HookEventDispatcherInterface::ENTITY_UPDATE);
  self::assertSame($entity, $event
    ->getEntity());
  self::assertSame($originalEntity, $event
    ->getOriginalEntity());
}