public function GroupContentEntityAccessControlHandlerTest::testCheckAccess in Group 8
Tests access.
@covers ::checkAccess @uses ::access
File
- tests/
src/ Unit/ GroupContentEntityAccessControlHandlerTest.php, line 92
Class
- GroupContentEntityAccessControlHandlerTest
- Tests the group content entity access control handler.
Namespace
Drupal\Tests\group\UnitCode
public function testCheckAccess() {
$content_enabler = $this
->prophesize(GroupContentEnablerInterface::class);
$language = $this
->prophesize(LanguageInterface::class);
$language
->getId()
->willReturn('nl');
$group_content = $this
->prophesize(GroupContentInterface::class);
$group_content
->id()
->willReturn(1337);
$group_content
->uuid()
->willReturn('baz');
$group_content
->language()
->willReturn($language
->reveal());
$group_content
->getRevisionId()
->willReturn(9001);
$group_content
->getEntityTypeId()
->willReturn('group_content');
$group_content
->getContentPlugin()
->willReturn($content_enabler
->reveal());
$access_result = AccessResult::allowed();
$content_enabler
->checkAccess($group_content
->reveal(), 'some_operation', $this->account
->reveal())
->shouldBeCalled()
->willReturn($access_result);
$result = $this->accessControlHandler
->access($group_content
->reveal(), 'some_operation', $this->account
->reveal());
$this
->assertEquals($access_result
->isAllowed(), $result);
}