public function UncacheableEntityAccessControlHandlerTest::createAccessProvider in Entity API 8
Data provider for testCreateAccess().
Return value
array A list of testCreateAccess method arguments.
File
- tests/
src/ Unit/ UncacheableEntityAccessControlHandlerTest.php, line 160
Class
- UncacheableEntityAccessControlHandlerTest
- @coversDefaultClass \Drupal\entity\UncacheableEntityAccessControlHandler @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(UncacheableEntityPermissionProvider::class);
// User with the admin permission.
$account = $this
->buildMockUser('6', 'administer green_entity');
$data[] = [
$entity_type
->reveal(),
NULL,
$account
->reveal(),
TRUE,
];
// Ordinary user.
$account = $this
->buildMockUser('6', 'create green_entity');
$data[] = [
$entity_type
->reveal(),
NULL,
$account
->reveal(),
TRUE,
];
// Ordinary user, entity with a bundle.
$account = $this
->buildMockUser('6', 'create first_bundle green_entity');
$data[] = [
$entity_type
->reveal(),
'first_bundle',
$account
->reveal(),
TRUE,
];
// User with no permissions.
$account = $this
->buildMockUser('6', 'access content');
$data[] = [
$entity_type
->reveal(),
NULL,
$account
->reveal(),
FALSE,
];
return $data;
}