UserAccessControlHandler example

->method('hasPermission')
      ->willReturnMap([
        ['view user email addresses', TRUE],
      ]);
    $this->emailViewer
      ->expects($this->any())
      ->method('id')
      ->willReturn(3);

    $entity_type = $this->createMock('Drupal\Core\Entity\EntityTypeInterface');

    $this->accessControlHandler = new UserAccessControlHandler($entity_type);
    $module_handler = $this->createMock('Drupal\Core\Extension\ModuleHandlerInterface');
    $this->accessControlHandler->setModuleHandler($module_handler);

    $this->items = $this->getMockBuilder('Drupal\Core\Field\FieldItemList')
      ->disableOriginalConstructor()
      ->getMock();
    $this->items
      ->expects($this->any())
      ->method('defaultAccess')
      ->willReturn(AccessResult::allowed());
  }

  
Home | Imprint | This part of the site doesn't use cookies.