function MediaLibraryAccessTest::testMediaLibraryImageStyleAccess

Same name in other branches
  1. 9 core/modules/media_library/tests/src/Kernel/MediaLibraryAccessTest.php \Drupal\Tests\media_library\Kernel\MediaLibraryAccessTest::testMediaLibraryImageStyleAccess()

Tests that users can't delete the 'media_library' image style.

File

core/modules/media_library/tests/src/Kernel/MediaLibraryAccessTest.php, line 89

Class

MediaLibraryAccessTest
Tests the media library access.

Namespace

Drupal\Tests\media_library\Kernel

Code

public function testMediaLibraryImageStyleAccess() {
    // Create a user who can manage the image styles.
    $user = $this->createUser([
        'access administration pages',
        'administer image styles',
    ]);
    // The user should be able to delete the 'medium' image style, but not the
    // 'media_library' image style.
    $this->assertTrue(ImageStyle::load('medium')->access('delete', $user));
    $this->assertFalse(ImageStyle::load('media_library')->access('delete', $user));
}

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