public function EntityAccessControlHandlerTest::createAccessProvider in Entity API 8
Data provider for testCreateAccess().
Return value
array A list of testCreateAccess method arguments.
File
- tests/
src/ Unit/ EntityAccessControlHandlerTest.php, line 158
Class
- EntityAccessControlHandlerTest
- @coversDefaultClass \Drupal\entity\EntityAccessControlHandler @group entity
Namespace
Drupal\Tests\entity\UnitCode
public function createAccessProvider() {
$data = [];
$entity_type = $this
->prophesize(ContentEntityTypeInterface::class);
$entity_type
->id()
->willReturn('green_entity');
$entity_type
->getAdminPermission()
->willReturn('administer green_entity');
$entity_type
->hasHandlerClass('permission_provider')
->willReturn(TRUE);
$entity_type
->getHandlerClass('permission_provider')
->willReturn(EntityPermissionProvider::class);
// User with the admin permission.
$account = $this
->buildMockUser('6', 'administer green_entity');
$data['admin user'] = [
$entity_type
->reveal(),
NULL,
$account
->reveal(),
TRUE,
[
'user.permissions',
],
];
// Ordinary user.
$account = $this
->buildMockUser('6', 'create green_entity');
$data['regular user'] = [
$entity_type
->reveal(),
NULL,
$account
->reveal(),
TRUE,
[
'user.permissions',
],
];
// Ordinary user, entity with a bundle.
$account = $this
->buildMockUser('6', 'create first_bundle green_entity');
$data['regular user, entity with bundle'] = [
$entity_type
->reveal(),
'first_bundle',
$account
->reveal(),
TRUE,
[
'user.permissions',
],
];
// User with no permissions.
$account = $this
->buildMockUser('6', 'access content');
$data['user without permission'] = [
$entity_type
->reveal(),
NULL,
$account
->reveal(),
FALSE,
[
'user.permissions',
],
];
return $data;
}