function AnnounceTestBase::setFeedItems

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

1 call to AnnounceTestBase::setFeedItems()
AnnounceRendererTest::testRendererContent in core/modules/announcements_feed/tests/src/Kernel/AnnounceRendererTest.php
Tests rendered valid content.
2 methods override AnnounceTestBase::setFeedItems()
AnnounceFetcherTest::setFeedItems in core/modules/announcements_feed/tests/src/Kernel/AnnounceFetcherTest.php
Sets the feed items to be returned for the test.
AnnounceFetcherUserTest::setFeedItems in core/modules/announcements_feed/tests/src/Kernel/AnnounceFetcherUserTest.php
Sets the feed items to be returned for the test.

File

core/modules/announcements_feed/tests/src/Kernel/AnnounceTestBase.php, line 52

Class

AnnounceTestBase
Base class for Announce Kernel tests.

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.