function AggregatorTestBase::createFeed

Same name in other branches
  1. 8.9.x core/modules/aggregator/src/Tests/AggregatorTestBase.php \Drupal\aggregator\Tests\AggregatorTestBase::createFeed()
  2. 8.9.x core/modules/aggregator/tests/src/Functional/AggregatorTestBase.php \Drupal\Tests\aggregator\Functional\AggregatorTestBase::createFeed()

Creates an aggregator feed.

This method simulates the form submission on path aggregator/sources/add.

Parameters

string $feed_url: (optional) If given, feed will be created with this URL, otherwise /rss.xml will be used. Defaults to NULL.

array $edit: Array with additional form fields.

Return value

\Drupal\aggregator\FeedInterface Full feed object if possible.

See also

getFeedEditArray()

22 calls to AggregatorTestBase::createFeed()
AddFeedTest::testAddFeed in core/modules/aggregator/tests/src/Functional/AddFeedTest.php
Creates and ensures that a feed is unique, checks source, and deletes feed.
AddFeedTest::testAddLongFeed in core/modules/aggregator/tests/src/Functional/AddFeedTest.php
Tests feeds with very long URLs.
AddFeedTest::testFeedLabelEscaping in core/modules/aggregator/tests/src/Functional/AddFeedTest.php
Ensures that the feed label is escaping when rendering the feed icon.
AggregatorAdminTest::testOverviewPage in core/modules/aggregator/tests/src/Functional/AggregatorAdminTest.php
Tests the overview page.
AggregatorCronTest::testCron in core/modules/aggregator/tests/src/Functional/AggregatorCronTest.php
Adds feeds and updates them via cron process.

... See full list

File

core/modules/aggregator/tests/src/Functional/AggregatorTestBase.php, line 75

Class

AggregatorTestBase
Defines a base class for testing the Aggregator module.

Namespace

Drupal\Tests\aggregator\Functional

Code

public function createFeed($feed_url = NULL, array $edit = []) {
    $edit = $this->getFeedEditArray($feed_url, $edit);
    $this->drupalGet('aggregator/sources/add');
    $this->submitForm($edit, 'Save');
    $this->assertSession()
        ->pageTextContains('The feed ' . $edit['title[0][value]'] . ' has been added.');
    // Verify that the creation message contains a link to a feed.
    $this->assertSession()
        ->elementExists('xpath', '//div[@data-drupal-messages]//a[contains(@href, "aggregator/sources/")]');
    $fids = \Drupal::entityQuery('aggregator_feed')->accessCheck(FALSE)
        ->condition('title', $edit['title[0][value]'])
        ->condition('url', $edit['url[0][value]'])
        ->execute();
    $this->assertNotEmpty($fids, 'The feed found in database.');
    return Feed::load(array_values($fids)[0]);
}

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