function AnnounceFetcherUserTest::testAllAnnouncementsFirst
Same name in other branches
- 10 core/modules/announcements_feed/tests/src/Kernel/AnnounceFetcherUserTest.php \Drupal\Tests\announcements_feed\Kernel\AnnounceFetcherUserTest::testAllAnnouncementsFirst()
Tests testAllAnnouncements should get all announcements.
First time accessing the announcements.
File
-
core/
modules/ announcements_feed/ tests/ src/ Kernel/ AnnounceFetcherUserTest.php, line 46
Class
- AnnounceFetcherUserTest
- @coversDefaultClass \Drupal\announcements_feed\AnnounceFetcher
Namespace
Drupal\Tests\announcements_feed\KernelCode
public function testAllAnnouncementsFirst() : void {
$this->markTestSkipped('Skipped due to major version-specific logic. See https://www.drupal.org/project/drupal/issues/3359322');
$feed_items = $this->providerShowAnnouncements();
// First time access.
$this->setFeedItems($feed_items);
$all_items = $this->container
->get('announcements_feed.fetcher')
->fetch();
$this->assertCount(4, $all_items);
$this->assertCount(1, $this->history);
// Second time access.
$this->setFeedItems($feed_items);
$all_items = $this->container
->get('announcements_feed.fetcher')
->fetch();
$this->assertCount(4, $all_items);
$this->assertCount(2, $this->history);
// Create another user and test again.
$permissions = [
'access toolbar',
'access announcements',
];
$this->setUpCurrentUser([
'uid' => 2,
], $permissions);
$this->setFeedItems($feed_items);
// First time access.
$all_items = $this->container
->get('announcements_feed.fetcher')
->fetch();
$this->assertCount(4, $all_items);
$this->assertCount(3, $this->history);
// Check after adding new record.
$feed_items = $this->providerShowUpdatedAnnouncements();
$this->setFeedItems($feed_items);
$all_items = $this->container
->get('announcements_feed.fetcher')
->fetch();
$this->assertCount(5, $all_items);
$this->assertSame('1005', $all_items[0]->id);
$this->assertCount(4, $this->history);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.