You are here

public function MediaAccessControlHandlerTest::testCreateAccess in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/media/tests/src/Kernel/MediaAccessControlHandlerTest.php \Drupal\Tests\media\Kernel\MediaAccessControlHandlerTest::testCreateAccess()

@covers ::checkCreateAccess @dataProvider providerCreateAccess

Parameters

string[] $permissions: User permissions.

\Drupal\Core\Access\AccessResultInterface $expected_result: Expected result.

string[] $expected_cache_contexts: Expected cache contexts.

string[] $expected_cache_tags: Expected cache tags.

File

core/modules/media/tests/src/Kernel/MediaAccessControlHandlerTest.php, line 74

Class

MediaAccessControlHandlerTest
Tests the media access control handler.

Namespace

Drupal\Tests\media\Kernel

Code

public function testCreateAccess(array $permissions, AccessResultInterface $expected_result, array $expected_cache_contexts, array $expected_cache_tags) {
  $user = $this
    ->createUser($permissions);

  /** @var \Drupal\Core\Entity\EntityAccessControlHandlerInterface $access_handler */
  $access_handler = $this->container
    ->get('entity_type.manager')
    ->getAccessControlHandler('media');
  $this
    ->assertAccess($expected_result, $expected_cache_contexts, $expected_cache_tags, $access_handler
    ->createAccess('test', $user, [], TRUE));
}