function MediaAccessControlHandlerTest::testRevisionLogFieldAccess
Same name in other branches
- 10 core/modules/media/tests/src/Kernel/MediaAccessControlHandlerTest.php \Drupal\Tests\media\Kernel\MediaAccessControlHandlerTest::testRevisionLogFieldAccess()
Tests access to the revision log field.
File
-
core/
modules/ media/ tests/ src/ Kernel/ MediaAccessControlHandlerTest.php, line 750
Class
- MediaAccessControlHandlerTest
- Tests the media access control handler.
Namespace
Drupal\Tests\media\KernelCode
public function testRevisionLogFieldAccess() : void {
$admin = $this->createUser([
'administer media',
'view media',
]);
$editor = $this->createUser([
'view all media revisions',
'view media',
]);
$viewer = $this->createUser([
'view media',
]);
$media_type = $this->createMediaType('test', [
'id' => 'test',
]);
$entity = Media::create([
'status' => TRUE,
'bundle' => $media_type->id(),
]);
$entity->save();
$this->assertTrue($entity->get('revision_log_message')
->access('view', $admin));
$this->assertTrue($entity->get('revision_log_message')
->access('view', $editor));
$this->assertFalse($entity->get('revision_log_message')
->access('view', $viewer));
$entity->setUnpublished()
->save();
\Drupal::entityTypeManager()->getAccessControlHandler('media')
->resetCache();
$this->assertFalse($entity->get('revision_log_message')
->access('view', $viewer));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.