public function MediaAccessControlHandlerTest::providerAccess in Drupal 8
Same name and namespace in other branches
- 9 core/modules/media/tests/src/Kernel/MediaAccessControlHandlerTest.php \Drupal\Tests\media\Kernel\MediaAccessControlHandlerTest::providerAccess()
Data provider for testAccess().
Return value
array The data sets to test.
File
- core/
modules/ media/ tests/ src/ Kernel/ MediaAccessControlHandlerTest.php, line 116
Class
- MediaAccessControlHandlerTest
- Tests the media access control handler.
Namespace
Drupal\Tests\media\KernelCode
public function providerAccess() {
$test_data = [];
// Check published / unpublished media access for a user owning the media
// item without permissions.
$test_data['owner, no permissions / published / view'] = [
[],
[
'status' => TRUE,
],
'view',
AccessResult::neutral(),
[
'user.permissions',
],
[
'media:1',
],
];
$test_data['owner, no permissions / published / update'] = [
[],
[
'status' => TRUE,
],
'update',
AccessResult::neutral(),
[
'user.permissions',
],
[],
];
$test_data['owner, no permissions / published / delete'] = [
[],
[
'status' => TRUE,
],
'delete',
AccessResult::neutral(),
[
'user.permissions',
],
[],
];
$test_data['owner, no permissions / unpublished / view'] = [
[],
[],
'view',
AccessResult::neutral(),
[
'user.permissions',
],
[
'media:1',
],
];
$test_data['owner, no permissions / unpublished / update'] = [
[],
[],
'update',
AccessResult::neutral(),
[
'user.permissions',
],
[],
];
$test_data['owner, no permissions / unpublished / delete'] = [
[],
[],
'delete',
AccessResult::neutral(),
[
'user.permissions',
],
[],
];
// Check published / unpublished media access for a user not owning the
// media item without permissions.
$test_data['not owner, no permissions / published / view'] = [
[],
[
'uid' => 0,
'status' => TRUE,
],
'view',
AccessResult::neutral(),
[
'user.permissions',
],
[
'media:1',
],
];
$test_data['not owner, no permissions / published / update'] = [
[],
[
'uid' => 0,
'status' => TRUE,
],
'update',
AccessResult::neutral(),
[
'user.permissions',
],
[],
];
$test_data['not owner, no permissions / published / delete'] = [
[],
[
'uid' => 0,
'status' => TRUE,
],
'delete',
AccessResult::neutral(),
[
'user.permissions',
],
[],
];
$test_data['not owner, no permissions / unpublished / view'] = [
[],
[
'uid' => 0,
],
'view',
AccessResult::neutral(),
[
'user.permissions',
],
[
'media:1',
],
];
$test_data['not owner, no permissions / unpublished / update'] = [
[],
[
'uid' => 0,
],
'update',
AccessResult::neutral(),
[
'user.permissions',
],
[],
];
$test_data['not owner, no permissions / unpublished / delete'] = [
[],
[
'uid' => 0,
],
'delete',
AccessResult::neutral(),
[
'user.permissions',
],
[],
];
// Check published / unpublished media access for a user owning the media
// item with only the 'view media' permission.
$test_data['owner, can view media / published / view'] = [
[
'view media',
],
[
'status' => TRUE,
],
'view',
AccessResult::allowed(),
[
'user.permissions',
],
[
'media:1',
],
];
$test_data['owner, can view media / published / update'] = [
[
'view media',
],
[
'status' => TRUE,
],
'update',
AccessResult::neutral(),
[
'user.permissions',
],
[],
];
$test_data['owner, can view media / published / delete'] = [
[
'view media',
],
[
'status' => TRUE,
],
'delete',
AccessResult::neutral(),
[
'user.permissions',
],
[],
];
$test_data['owner, can view media / unpublished / view'] = [
[
'view media',
],
[],
'view',
AccessResult::neutral(),
[
'user.permissions',
],
[
'media:1',
],
];
$test_data['owner, can view media / unpublished / update'] = [
[
'view media',
],
[],
'update',
AccessResult::neutral(),
[
'user.permissions',
],
[],
];
$test_data['owner, can view media / unpublished / delete'] = [
[
'view media',
],
[],
'delete',
AccessResult::neutral(),
[
'user.permissions',
],
[],
];
// Check published / unpublished media access for a user not owning the
// media item with only the 'view media' permission.
$test_data['not owner, can view media / published / view'] = [
[
'view media',
],
[
'uid' => 0,
'status' => TRUE,
],
'view',
AccessResult::allowed(),
[
'user.permissions',
],
[
'media:1',
],
];
$test_data['not owner, can view media / published / update'] = [
[
'view media',
],
[
'uid' => 0,
'status' => TRUE,
],
'update',
AccessResult::neutral(),
[
'user.permissions',
],
[],
];
$test_data['not owner, can view media / published / delete'] = [
[
'view media',
],
[
'uid' => 0,
'status' => TRUE,
],
'delete',
AccessResult::neutral(),
[
'user.permissions',
],
[],
];
$test_data['not owner, can view media / unpublished / view'] = [
[
'view media',
],
[
'uid' => 0,
],
'view',
AccessResult::neutral(),
[
'user.permissions',
],
[
'media:1',
],
];
$test_data['not owner, can view media / unpublished / update'] = [
[
'view media',
],
[
'uid' => 0,
],
'update',
AccessResult::neutral(),
[
'user.permissions',
],
[],
];
$test_data['not owner, can view media / unpublished / delete'] = [
[
'view media',
],
[
'uid' => 0,
],
'delete',
AccessResult::neutral(),
[
'user.permissions',
],
[],
];
// Check published / unpublished media access for a user owning the media
// item with the 'view media' and 'view own unpublished' permission.
$test_data['owner, can view own unpublished media / published / view'] = [
[
'view media',
'view own unpublished media',
],
[
'status' => TRUE,
],
'view',
AccessResult::allowed(),
[
'user.permissions',
],
[
'media:1',
],
];
$test_data['owner, can view own unpublished media / published / update'] = [
[
'view media',
'view own unpublished media',
],
[
'status' => TRUE,
],
'update',
AccessResult::neutral(),
[
'user.permissions',
],
[],
];
$test_data['owner, can view own unpublished media / published / delete'] = [
[
'view media',
'view own unpublished media',
],
[
'status' => TRUE,
],
'delete',
AccessResult::neutral(),
[
'user.permissions',
],
[],
];
$test_data['owner, can view own unpublished media / unpublished / view'] = [
[
'view media',
'view own unpublished media',
],
[],
'view',
AccessResult::allowed(),
[
'user.permissions',
'user',
],
[
'media:1',
],
];
$test_data['owner, can view own unpublished media / unpublished / update'] = [
[
'view media',
'view own unpublished media',
],
[],
'update',
AccessResult::neutral(),
[
'user.permissions',
],
[],
];
$test_data['owner, can view own unpublished media / unpublished / delete'] = [
[
'view media',
'view own unpublished media',
],
[],
'delete',
AccessResult::neutral(),
[
'user.permissions',
],
[],
];
// Check published / unpublished media access for a user not owning the
// media item with the 'view media' and 'view own unpublished' permission.
$test_data['not owner, can view own unpublished media / published / view'] = [
[
'view media',
'view own unpublished media',
],
[
'uid' => 0,
'status' => TRUE,
],
'view',
AccessResult::allowed(),
[
'user.permissions',
],
[
'media:1',
],
];
$test_data['not owner, can view own unpublished media / published / update'] = [
[
'view media',
'view own unpublished media',
],
[
'uid' => 0,
'status' => TRUE,
],
'update',
AccessResult::neutral(),
[
'user.permissions',
],
[],
];
$test_data['not owner, can view own unpublished media / published / delete'] = [
[
'view media',
'view own unpublished media',
],
[
'uid' => 0,
'status' => TRUE,
],
'delete',
AccessResult::neutral(),
[
'user.permissions',
],
[],
];
$test_data['not owner, can view own unpublished media / unpublished / view'] = [
[
'view media',
'view own unpublished media',
],
[
'uid' => 0,
],
'view',
AccessResult::neutral(),
[
'user.permissions',
'user',
],
[
'media:1',
],
];
$test_data['not owner, can view own unpublished media / unpublished / update'] = [
[
'view media',
'view own unpublished media',
],
[
'uid' => 0,
],
'update',
AccessResult::neutral(),
[
'user.permissions',
],
[],
];
$test_data['not owner, can view own unpublished media / unpublished / delete'] = [
[
'view media',
'view own unpublished media',
],
[
'uid' => 0,
],
'delete',
AccessResult::neutral(),
[
'user.permissions',
],
[],
];
return $test_data;
}