You are here

public function MediaLibraryAccessTest::testMediaLibraryImageStyleAccess in Drupal 9

Same name and namespace in other branches
  1. 8 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));
}