Commit e2c898cc authored by catch's avatar catch

Issue #2905213 by chr.fritsch, marcoscano, xjm, Berdir: Bring back 'access...

Issue #2905213 by chr.fritsch, marcoscano, xjm, Berdir: Bring back 'access media overview' permission
parent 278c50e0
...@@ -27,3 +27,7 @@ create media: ...@@ -27,3 +27,7 @@ create media:
view all media revisions: view all media revisions:
title: 'View all media revisions' title: 'View all media revisions'
description: 'To view a revision, you also need permission to view the media item.' description: 'To view a revision, you also need permission to view the media item.'
access media overview:
title: 'Access media overview'
description: 'Users with this permission can access the media overview page.'
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* *
* @group media * @group media
*/ */
class MediaAccessTest extends MediaFunctionalTestBase { class MediaAccessTest extends MediaUiFunctionalTest {
use AssertPageCacheContextsAndTagsTrait; use AssertPageCacheContextsAndTagsTrait;
...@@ -64,7 +64,7 @@ public function testMediaAccess() { ...@@ -64,7 +64,7 @@ public function testMediaAccess() {
$this->assertSame("The 'view media' permission is required and the media item must be published.", $access_result->getReason()); $this->assertSame("The 'view media' permission is required and the media item must be published.", $access_result->getReason());
$this->grantPermissions($role, ['view media']); $this->grantPermissions($role, ['view media']);
$this->drupalGet('media/' . $media->id()); $this->drupalGet('media/' . $media->id());
$this->assertCacheContext('user.permissions'); $this->assertCacheContext('user');
$assert_session->statusCodeEquals(200); $assert_session->statusCodeEquals(200);
// Test 'create media' permission. // Test 'create media' permission.
...@@ -107,6 +107,28 @@ public function testMediaAccess() { ...@@ -107,6 +107,28 @@ public function testMediaAccess() {
$this->drupalGet('media/' . $media->id() . '/delete'); $this->drupalGet('media/' . $media->id() . '/delete');
$this->assertCacheContext('user.permissions'); $this->assertCacheContext('user.permissions');
$assert_session->statusCodeEquals(200); $assert_session->statusCodeEquals(200);
// Test the 'access media overview' permission.
$this->grantPermissions($role, ['access content overview']);
$this->drupalGet('admin/content');
$assert_session->linkByHrefNotExists('/admin/content/media');
$this->assertCacheContext('user');
// Create a new role, which implicitly checks if the permission exists.
$mediaOverviewRole = $this->createRole(['access content overview', 'access media overview']);
$this->nonAdminUser->addRole($mediaOverviewRole);
$this->nonAdminUser->save();
$this->drupalGet('admin/content');
$assert_session->linkByHrefExists('/admin/content/media');
$this->clickLink('Media');
$this->assertCacheContext('user.permissions');
$assert_session->statusCodeEquals(200);
$assert_session->elementExists('css', '.view-media');
$assert_session->pageTextContains($this->loggedInUser->getDisplayName());
$assert_session->pageTextContains($this->nonAdminUser->getDisplayName());
$assert_session->linkByHrefExists('/media/' . $media->id());
$assert_session->linkByHrefExists('/media/' . $user_media->id());
} }
} }
...@@ -45,7 +45,7 @@ trait MediaFunctionalTestTrait { ...@@ -45,7 +45,7 @@ trait MediaFunctionalTestTrait {
/** /**
* A non-admin test user account. * A non-admin test user account.
* *
* @var \Drupal\Core\Session\AccountInterface * @var \Drupal\user\UserInterface
*/ */
protected $nonAdminUser; protected $nonAdminUser;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment