You are here

public function EntityAccessEventTest::testEntityAccessEventWithNoChanges in Hook Event Dispatcher 3.x

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

EntityAccessEvent with no changes test.

File

modules/core_event_dispatcher/tests/src/Unit/Entity/EntityAccessEventTest.php, line 46

Class

EntityAccessEventTest
Class EntityAccessEventTest.

Namespace

Drupal\Tests\core_event_dispatcher\Unit\Entity

Code

public function testEntityAccessEventWithNoChanges() : void {
  $entity = $this
    ->createMock(EntityInterface::class);
  $operation = 'test';
  $account = $this
    ->createMock(AccountInterface::class);
  $hookAccessResult = core_event_dispatcher_entity_access($entity, $operation, $account);

  /** @var \Drupal\core_event_dispatcher\Event\Entity\EntityAccessEvent $event */
  $event = $this->manager
    ->getRegisteredEvent(HookEventDispatcherInterface::ENTITY_ACCESS);
  self::assertSame($entity, $event
    ->getEntity());
  self::assertSame($operation, $event
    ->getOperation());
  self::assertSame($account, $event
    ->getAccount());
  self::assertTrue($hookAccessResult
    ->isNeutral());
  self::assertFalse($hookAccessResult
    ->isAllowed());
  self::assertFalse($hookAccessResult
    ->isForbidden());
}