You are here

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

Test EntityPresaveEvent.

File

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

Class

EntityEventTest
Class EntityEventTest.

Namespace

Drupal\Tests\core_event_dispatcher\Unit\Entity

Code

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

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