public function EntityEventTest::testEntityPresaveEvent in Hook Event Dispatcher 8
Test EntityPresaveEvent.
File
- tests/
src/ Unit/ Entity/ EntityEventTest.php, line 138
Class
- EntityEventTest
- Class EntityEventTest.
Namespace
Drupal\Tests\hook_event_dispatcher\Unit\EntityCode
public function testEntityPresaveEvent() {
$entity = $this
->createMock(EntityInterface::class);
$originalEntity = $this
->createMock(EntityInterface::class);
$entity->original = $originalEntity;
hook_event_dispatcher_entity_presave($entity);
/** @var \Drupal\hook_event_dispatcher\Event\Entity\EntityPresaveEvent $event */
$event = $this->manager
->getRegisteredEvent(HookEventDispatcherInterface::ENTITY_PRE_SAVE);
self::assertEquals($entity, $event
->getEntity());
self::assertEquals($originalEntity, $event
->getOriginalEntity());
}