function MediaLibraryAccessTest::testMediaLibraryImageStyleAccess

Same name in other branches
  1. 8.9.x 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 91

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.