$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'
);
$assert_session->
statusCodeEquals(200
);
$assert_session->
elementExists('css', '.views-element-container'
);
// First row of the View contains media created by admin user.
$assert_session->
elementTextEquals('xpath', '//div[@class="views-element-container"]//tbody/tr[1]/td[contains(@class, "views-field-uid")]/a',
$this->adminUser->
getDisplayName());
$assert_session->
elementTextEquals('xpath', "//div[@class='views-element-container']//tbody/tr[1]/td[contains(@class, 'views-field-name')]/a[contains(@href, '/media/{
$media->
id()}')]", 'Unnamed'
);
// Second row of the View contains media created by non-admin user.
$assert_session->
elementTextEquals('xpath', '//div[@class="views-element-container"]//tbody/tr[2]/td[contains(@class, "views-field-uid")]/a',
$this->nonAdminUser->
getDisplayName());
$assert_session->
elementTextEquals('xpath', "//div[@class='views-element-container']//tbody/tr[2]/td[contains(@class, 'views-field-name')]/a[contains(@href, '/media/{
$user_media->
id()}')]", 'Unnamed'
);
} /**
* Tests view access control on the canonical page.
*/
public function testCanonicalMediaAccess() { $media_type =
$this->
createMediaType('test'
);