public function EntityAccessEventTest::testEntityAccessEventNeutralResult in Hook Event Dispatcher 8
EntityAccessEvent with neutral result test.
File
- tests/
src/ Unit/ Entity/ EntityAccessEventTest.php, line 108
Class
- EntityAccessEventTest
- Class EntityAccessEventTest.
Namespace
Drupal\Tests\hook_event_dispatcher\Unit\EntityCode
public function testEntityAccessEventNeutralResult() {
$accessResult = new AccessResultNeutral();
$this->manager
->setEventCallbacks([
HookEventDispatcherInterface::ENTITY_ACCESS => function (EntityAccessEvent $event) use ($accessResult) {
$event
->addAccessResult($accessResult);
},
]);
$entity = $this
->createMock(EntityInterface::class);
$operation = 'test';
$account = $this
->createMock(AccountInterface::class);
$hookAccessResult = hook_event_dispatcher_entity_access($entity, $operation, $account);
self::assertTrue($hookAccessResult
->isNeutral());
self::assertFalse($hookAccessResult
->isAllowed());
self::assertFalse($hookAccessResult
->isForbidden());
}