function AnnounceFetcherUserTest::setFeedItems

Same name and namespace in other branches
  1. 10 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 <a href="/api/drupal/core%21modules%21announcements_feed%21src%21AnnounceFetcher.php/class/AnnounceFetcher/11.x" title="Service to fetch announcements from the external feed." class="local">\Drupal\announcements_feed\AnnounceFetcher</a>

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.