Skip to content
Snippets Groups Projects
Select Git revision
  • 608336e9252e56604b8d38dcdf7546f3ba98b310
  • 11.x default protected
  • 11.2.x protected
  • 10.5.x protected
  • 10.6.x protected
  • 11.1.x protected
  • 10.4.x protected
  • 11.0.x protected
  • 10.3.x protected
  • 7.x protected
  • 10.2.x protected
  • 10.1.x protected
  • 9.5.x protected
  • 10.0.x protected
  • 9.4.x protected
  • 9.3.x protected
  • 9.2.x protected
  • 9.1.x protected
  • 8.9.x protected
  • 9.0.x protected
  • 8.8.x protected
  • 10.5.1 protected
  • 11.2.2 protected
  • 11.2.1 protected
  • 11.2.0 protected
  • 10.5.0 protected
  • 11.2.0-rc2 protected
  • 10.5.0-rc1 protected
  • 11.2.0-rc1 protected
  • 10.4.8 protected
  • 11.1.8 protected
  • 10.5.0-beta1 protected
  • 11.2.0-beta1 protected
  • 11.2.0-alpha1 protected
  • 10.4.7 protected
  • 11.1.7 protected
  • 10.4.6 protected
  • 11.1.6 protected
  • 10.3.14 protected
  • 10.4.5 protected
  • 11.0.13 protected
41 results

MenuLinkContentEntityAccessTest.php

Blame
  • Lee Rowlands's avatar
    Issue #3016038 by dpi, acbramley, jibran, dww, phenaproxima, jungle, Mingsong:...
    Lee Rowlands authored
    Issue #3016038 by dpi, acbramley, jibran, dww, phenaproxima, jungle, Mingsong: Unrecognised entity operation passed to Menu Link Content throws exceptions
    
    (cherry picked from commit 5920411f)
    608336e9
    History
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    MenuLinkContentEntityAccessTest.php 1.80 KiB
    <?php
    
    namespace Drupal\Tests\menu_link_content\Unit;
    
    use Drupal\Core\Access\AccessManagerInterface;
    use Drupal\Core\Access\AccessResultInterface;
    use Drupal\Core\Entity\ContentEntityInterface;
    use Drupal\Core\Entity\EntityTypeInterface;
    use Drupal\Core\Extension\ModuleHandlerInterface;
    use Drupal\Core\Language\LanguageInterface;
    use Drupal\Core\Session\AccountInterface;
    use Drupal\menu_link_content\MenuLinkContentAccessControlHandler;
    use Drupal\Tests\UnitTestCase;
    
    /**
     * Tests menu link content entity access.
     *
     * @coversDefaultClass \Drupal\menu_link_content\MenuLinkContentAccessControlHandler
     * @group menu_link_content
     */
    class MenuLinkContentEntityAccessTest extends UnitTestCase {
    
      /**
       * Tests an operation not implemented by the access control handler.
       *
       * @covers ::checkAccess
       */
      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);
      }
    
    }