function MediaLibraryWidgetTest::testRevisionableWidgetAccess

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

Class

MediaLibraryWidgetTest
Tests the media library widget.

Namespace

Drupal\Tests\media_library\Kernel

Code

public function testRevisionableWidgetAccess() : void {
    $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']);
}

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