function ContentEntityBaseUnitTest::testAccess
Same name in other branches
- 8.9.x core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php \Drupal\Tests\Core\Entity\ContentEntityBaseUnitTest::testAccess()
- 10 core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php \Drupal\Tests\Core\Entity\ContentEntityBaseUnitTest::testAccess()
- 11.x 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 505
Class
- ContentEntityBaseUnitTest
- @coversDefaultClass \Drupal\Core\Entity\ContentEntityBase @group Entity @group Access
Namespace
Drupal\Tests\Core\EntityCode
public function testAccess() {
$access = $this->createMock('\\Drupal\\Core\\Entity\\EntityAccessControlHandlerInterface');
$operation = $this->randomMachineName();
$access->expects($this->exactly(2))
->method('access')
->with($this->entity, $operation)
->willReturnOnConsecutiveCalls(TRUE, AccessResult::allowed());
$access->expects($this->exactly(2))
->method('createAccess')
->willReturnOnConsecutiveCalls(TRUE, AccessResult::allowed());
$this->entityTypeManager
->expects($this->exactly(4))
->method('getAccessControlHandler')
->willReturn($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));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.