function AnnounceFetcherUserTest::setFeedItems

Same name in other branches
  1. 11.x core/modules/announcements_feed/tests/src/Kernel/AnnounceFetcherUserTest.php \Drupal\Tests\announcements_feed\Kernel\AnnounceFetcherUserTest::setFeedItems()

Sets the feed items to be returned for the test.

Parameters

mixed[][] $feed_items: The feeds items to test. Every time the http_client makes a request the next item in this array will be returned. For each feed item 'title' and 'url' are omitted because they do not need to vary between test cases.

Overrides AnnounceTestBase::setFeedItems

1 call to AnnounceFetcherUserTest::setFeedItems()
AnnounceFetcherUserTest::testAllAnnouncementsFirst in core/modules/announcements_feed/tests/src/Kernel/AnnounceFetcherUserTest.php
Tests testAllAnnouncements should get all announcements.

File

core/modules/announcements_feed/tests/src/Kernel/AnnounceFetcherUserTest.php, line 220

Class

AnnounceFetcherUserTest
@coversDefaultClass \Drupal\announcements_feed\AnnounceFetcher

Namespace

Drupal\Tests\announcements_feed\Kernel

Code

protected function setFeedItems(array $feed_items) : void {
    $responses[] = new Response(200, [], json_encode([
        'items' => $feed_items,
    ]));
    $responses[] = new Response(200, [], json_encode([
        'items' => $feed_items,
    ]));
    $responses[] = new Response(200, [], json_encode([
        'items' => $feed_items,
    ]));
    $this->setTestFeedResponses($responses);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.