public function EntityUnitTest::testAccess in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php \Drupal\Tests\Core\Entity\EntityUnitTest::testAccess()
- 9 core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php \Drupal\Tests\Core\Entity\EntityUnitTest::testAccess()
@covers ::access
File
- core/
tests/ Drupal/ Tests/ Core/ Entity/ EntityUnitTest.php, line 195
Class
- EntityUnitTest
- @coversDefaultClass \Drupal\Core\Entity\EntityBase @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
->once())
->method('access')
->with($this->entity, $operation)
->will($this
->returnValue(AccessResult::allowed()));
$access
->expects($this
->once())
->method('createAccess')
->will($this
->returnValue(AccessResult::allowed()));
$this->entityTypeManager
->expects($this
->exactly(2))
->method('getAccessControlHandler')
->will($this
->returnValue($access));
$this
->assertEquals(AccessResult::allowed(), $this->entity
->access($operation));
$this
->assertEquals(AccessResult::allowed(), $this->entity
->access('create'));
}