public function ContentEntityBaseUnitTest::testAccess in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php \Drupal\Tests\Core\Entity\ContentEntityBaseUnitTest::testAccess()
@covers ::access
File
- core/
tests/ Drupal/ Tests/ Core/ Entity/ ContentEntityBaseUnitTest.php, line 421 - Contains \Drupal\Tests\Core\Entity\ContentEntityBaseUnitTest.
Class
- ContentEntityBaseUnitTest
- @coversDefaultClass \Drupal\Core\Entity\ContentEntityBase @group Entity @group Access
Namespace
Drupal\Tests\Core\EntityCode
public function testAccess() {
$access = $this
->getMock('\\Drupal\\Core\\Entity\\EntityAccessControlHandlerInterface');
$operation = $this
->randomMachineName();
$access
->expects($this
->at(0))
->method('access')
->with($this->entity, $operation)
->will($this
->returnValue(TRUE));
$access
->expects($this
->at(1))
->method('access')
->with($this->entity, $operation)
->will($this
->returnValue(AccessResult::allowed()));
$access
->expects($this
->at(2))
->method('createAccess')
->will($this
->returnValue(TRUE));
$access
->expects($this
->at(3))
->method('createAccess')
->will($this
->returnValue(AccessResult::allowed()));
$this->entityManager
->expects($this
->exactly(4))
->method('getAccessControlHandler')
->will($this
->returnValue($access));
$this
->assertTrue($this->entity
->access($operation));
$this
->assertEquals(AccessResult::allowed(), $this->entity
->access($operation, NULL, TRUE));
$this
->assertTrue($this->entity
->access('create'));
$this
->assertEquals(AccessResult::allowed(), $this->entity
->access('create', NULL, TRUE));
}