summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathaniel Catchpole2017-10-02 16:23:50 (GMT)
committerNathaniel Catchpole2017-10-02 16:23:50 (GMT)
commite2c898ccd199f674fe3fccf324adfdca540f4ac7 (patch)
tree453f9fd4fad2cae4f52fdb2c476dde85a1dd6516
parent278c50e0dc096fa21739a24949cf979ef3137659 (diff)
Issue #2905213 by chr.fritsch, marcoscano, xjm, Berdir: Bring back 'access media overview' permission
-rw-r--r--core/modules/media/media.permissions.yml4
-rw-r--r--core/modules/media/tests/src/Functional/MediaAccessTest.php26
-rw-r--r--core/modules/media/tests/src/Functional/MediaFunctionalTestTrait.php2
3 files changed, 29 insertions, 3 deletions
diff --git a/core/modules/media/media.permissions.yml b/core/modules/media/media.permissions.yml
index 79eadb5..107882c 100644
--- a/core/modules/media/media.permissions.yml
+++ b/core/modules/media/media.permissions.yml
@@ -27,3 +27,7 @@ create media:
view all media revisions:
title: 'View all media revisions'
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.'
diff --git a/core/modules/media/tests/src/Functional/MediaAccessTest.php b/core/modules/media/tests/src/Functional/MediaAccessTest.php
index ba02f08..d5c2304 100644
--- a/core/modules/media/tests/src/Functional/MediaAccessTest.php
+++ b/core/modules/media/tests/src/Functional/MediaAccessTest.php
@@ -12,7 +12,7 @@ use Drupal\user\RoleInterface;
*
* @group media
*/
-class MediaAccessTest extends MediaFunctionalTestBase {
+class MediaAccessTest extends MediaUiFunctionalTest {
use AssertPageCacheContextsAndTagsTrait;
@@ -64,7 +64,7 @@ class MediaAccessTest extends MediaFunctionalTestBase {
$this->assertSame("The 'view media' permission is required and the media item must be published.", $access_result->getReason());
$this->grantPermissions($role, ['view media']);
$this->drupalGet('media/' . $media->id());
- $this->assertCacheContext('user.permissions');
+ $this->assertCacheContext('user');
$assert_session->statusCodeEquals(200);
// Test 'create media' permission.
@@ -107,6 +107,28 @@ class MediaAccessTest extends MediaFunctionalTestBase {
$this->drupalGet('media/' . $media->id() . '/delete');
$this->assertCacheContext('user.permissions');
$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());
}
}
diff --git a/core/modules/media/tests/src/Functional/MediaFunctionalTestTrait.php b/core/modules/media/tests/src/Functional/MediaFunctionalTestTrait.php
index 75e0d06..d56e156 100644
--- a/core/modules/media/tests/src/Functional/MediaFunctionalTestTrait.php
+++ b/core/modules/media/tests/src/Functional/MediaFunctionalTestTrait.php
@@ -45,7 +45,7 @@ trait MediaFunctionalTestTrait {
/**
* A non-admin test user account.
*
- * @var \Drupal\Core\Session\AccountInterface
+ * @var \Drupal\user\UserInterface
*/
protected $nonAdminUser;