public function GroupContentEntityAccessControlHandlerTest::testCheckCreateAccess in Group 8
Tests create access.
@covers ::checkCreateAccess @uses ::createAccess
File
- tests/
src/ Unit/ GroupContentEntityAccessControlHandlerTest.php, line 122
Class
- GroupContentEntityAccessControlHandlerTest
- Tests the group content entity access control handler.
Namespace
Drupal\Tests\group\UnitCode
public function testCheckCreateAccess() {
$group = $this
->prophesize(GroupInterface::class);
$content_enabler = $this
->prophesize(GroupContentEnablerInterface::class);
$group_content_type = $this
->prophesize(GroupContentTypeInterface::class);
$group_content_type
->getContentPlugin()
->willReturn($content_enabler
->reveal());
$group_content_type_storage = $this
->prophesize(GroupContentTypeStorageInterface::class);
$group_content_type_storage
->load('foo')
->willReturn($group_content_type
->reveal());
$this->entityTypeManager
->getStorage('group_content_type')
->willReturn($group_content_type_storage
->reveal());
$access_result = AccessResult::allowed();
$content_enabler
->createAccess($group
->reveal(), $this->account
->reveal())
->shouldBeCalled()
->willReturn($access_result);
$result = $this->accessControlHandler
->createAccess('foo', $this->account
->reveal(), [
'group' => $group
->reveal(),
]);
$this
->assertEquals($access_result
->isAllowed(), $result);
}