function MenuLinkContentEntityAccessTest::testUnrecognizedOperation

Same name in other branches
  1. 9 core/modules/menu_link_content/tests/src/Unit/MenuLinkContentEntityAccessTest.php \Drupal\Tests\menu_link_content\Unit\MenuLinkContentEntityAccessTest::testUnrecognizedOperation()
  2. 10 core/modules/menu_link_content/tests/src/Unit/MenuLinkContentEntityAccessTest.php \Drupal\Tests\menu_link_content\Unit\MenuLinkContentEntityAccessTest::testUnrecognizedOperation()
  3. 11.x core/modules/menu_link_content/tests/src/Unit/MenuLinkContentEntityAccessTest.php \Drupal\Tests\menu_link_content\Unit\MenuLinkContentEntityAccessTest::testUnrecognizedOperation()

Tests an operation not implemented by the access control handler.

@covers ::checkAccess

File

core/modules/menu_link_content/tests/src/Unit/MenuLinkContentEntityAccessTest.php, line 28

Class

MenuLinkContentEntityAccessTest
Tests menu link content entity access.

Namespace

Drupal\Tests\menu_link_content\Unit

Code

public function testUnrecognizedOperation() {
    $entityType = $this->createMock(EntityTypeInterface::class);
    $accessManager = $this->createMock(AccessManagerInterface::class);
    $moduleHandler = $this->createMock(ModuleHandlerInterface::class);
    $moduleHandler->expects($this->any())
        ->method('invokeAll')
        ->willReturn([]);
    $language = $this->createMock(LanguageInterface::class);
    $language->expects($this->any())
        ->method('getId')
        ->will($this->returnValue('de'));
    $entity = $this->createMock(ContentEntityInterface::class);
    $entity->expects($this->any())
        ->method('language')
        ->willReturn($language);
    $account = $this->createMock(AccountInterface::class);
    $accessControl = new MenuLinkContentAccessControlHandler($entityType, $accessManager);
    $accessControl->setModuleHandler($moduleHandler);
    $access = $accessControl->access($entity, 'not-an-op', $account, TRUE);
    $this->assertInstanceOf(AccessResultInterface::class, $access);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.