function AnnounceFetcherTest::setFeedItems

Same name in other branches
  1. 11.x core/modules/announcements_feed/tests/src/Kernel/AnnounceFetcherTest.php \Drupal\Tests\announcements_feed\Kernel\AnnounceFetcherTest::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

2 calls to AnnounceFetcherTest::setFeedItems()
AnnounceFetcherTest::testFeedFields in core/modules/announcements_feed/tests/src/Kernel/AnnounceFetcherTest.php
Tests feed fields.
AnnounceFetcherTest::testShowAnnouncements in core/modules/announcements_feed/tests/src/Kernel/AnnounceFetcherTest.php
Tests announcement that should be displayed.

File

core/modules/announcements_feed/tests/src/Kernel/AnnounceFetcherTest.php, line 134

Class

AnnounceFetcherTest
@coversDefaultClass \Drupal\announcements_feed\AnnounceFetcher

Namespace

Drupal\Tests\announcements_feed\Kernel

Code

protected function setFeedItems(array $feed_items) : void {
    $responses = [];
    foreach ($feed_items as $feed_item) {
        $feed_item += [
            'title' => 'Drupal security update Test',
            'url' => 'https://www.drupal.org/project/announce',
        ];
        $responses[] = new Response(200, [], json_encode([
            'items' => [
                $feed_item,
            ],
        ]));
    }
    $this->setTestFeedResponses($responses);
}

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