function MediaAccessControlHandlerTest::testCreateAccess

Same name in other branches
  1. 9 core/modules/media/tests/src/Kernel/MediaAccessControlHandlerTest.php \Drupal\Tests\media\Kernel\MediaAccessControlHandlerTest::testCreateAccess()
  2. 8.9.x core/modules/media/tests/src/Kernel/MediaAccessControlHandlerTest.php \Drupal\Tests\media\Kernel\MediaAccessControlHandlerTest::testCreateAccess()
  3. 11.x 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 94

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) : void {
    $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));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.