public function FeedListBuilderTest::testUiWithOnlyViewPermissions in Feeds 8.3
Tests the feed listing page for an user who may only view feeds.
File
- tests/
src/ Functional/ FeedListBuilderTest.php, line 60
Class
- FeedListBuilderTest
- Tests the feed listing page.
Namespace
Drupal\Tests\feeds\FunctionalCode
public function testUiWithOnlyViewPermissions() {
// Add two feed types.
$feed_type_1 = $this
->createFeedType();
$feed_type_2 = $this
->createFeedType();
// Add two feeds.
$this
->createFeed($feed_type_1
->id(), [
'title' => 'My feed 1',
'source' => $this
->resourcesUrl() . '/rss/googlenewstz.rss2',
]);
$this
->createFeed($feed_type_2
->id(), [
'title' => 'My feed 2',
'source' => $this
->resourcesUrl() . '/rss/googlenewstz.rss2',
]);
// Login as an user who may only view the first feed.
$account = $this
->drupalCreateUser([
'access feed overview',
'view ' . $feed_type_1
->id() . ' feeds',
]);
$this
->drupalLogin($account);
// Go to the feed listing page.
$this
->drupalGet('admin/content/feed');
$session = $this
->assertSession();
// Assert that there are no warnings nor errors displayed.
$this
->assertNoWarnings();
// Assert the first feed listed with the expected links.
$session
->pageTextContains('My feed 1');
$session
->linkByHrefExists('/feed/1');
// Assert that the second feed is *not* listed.
$session
->pageTextNotContains('My feed 2');
$session
->linkByHrefNotExists('/feed/2');
// Assert that the following links do *not* exist for both feeds.
$session
->linkNotExists('Edit');
$session
->linkByHrefNotExists('/feed/1/edit');
$session
->linkByHrefNotExists('/feed/2/edit');
$session
->linkNotExists('Import');
$session
->linkByHrefNotExists('/feed/1/import');
$session
->linkByHrefNotExists('/feed/2/import');
$session
->linkNotExists('Import in background');
$session
->linkByHrefNotExists('/feed/1/schedule-import');
$session
->linkByHrefNotExists('/feed/2/schedule-import');
$session
->linkNotExists('Delete items');
$session
->linkByHrefNotExists('/feed/1/delete-items');
$session
->linkByHrefNotExists('/feed/2/delete-items');
}