public function MediaLibraryWidgetTest::testRevisionableWidgetAccess in Drupal 8
Same name and namespace in other branches
- 9 core/modules/media_library/tests/src/Kernel/MediaLibraryWidgetTest.php \Drupal\Tests\media_library\Kernel\MediaLibraryWidgetTest::testRevisionableWidgetAccess()
Test the media library widget access with a revisionable entity type.
File
- core/
modules/ media_library/ tests/ src/ Kernel/ MediaLibraryWidgetTest.php, line 102
Class
- MediaLibraryWidgetTest
- Tests the media library widget.
Namespace
Drupal\Tests\media_library\KernelCode
public function testRevisionableWidgetAccess() {
$allowed_revision = EntityTestRev::create([
'name' => 'allowed_access',
]);
$allowed_revision
->save();
$denied_revision = clone $allowed_revision;
$denied_revision
->setNewRevision();
$denied_revision->name = 'forbid_access';
$denied_revision
->save();
$element = $this
->buildWidgetForm($allowed_revision);
$this
->assertMediaLibraryStateAccess(TRUE, $this->adminUser, $element['open_button']['#media_library_state']);
$element = $this
->buildWidgetForm($denied_revision);
$this
->assertMediaLibraryStateAccess(FALSE, $this->adminUser, $element['open_button']['#media_library_state']);
}