You are here

public function AggregatorTestBase::getFeedEditObject in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/aggregator/tests/src/Functional/AggregatorTestBase.php \Drupal\Tests\aggregator\Functional\AggregatorTestBase::getFeedEditObject()

Returns a randomly generated feed edit object.

Parameters

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

array $values: (optional) Default values to initialize object properties with.

Return value

\Drupal\aggregator\FeedInterface A feed object.

File

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

Class

AggregatorTestBase
Defines a base class for testing the Aggregator module.

Namespace

Drupal\Tests\aggregator\Functional

Code

public function getFeedEditObject($feed_url = NULL, array $values = []) {
  $feed_name = $this
    ->randomMachineName(10);
  if (!$feed_url) {
    $feed_url = Url::fromRoute('view.frontpage.feed_1', [
      'query' => [
        'feed' => $feed_name,
      ],
      'absolute' => TRUE,
    ])
      ->toString();
  }
  $values += [
    'title' => $feed_name,
    'url' => $feed_url,
    'refresh' => '900',
  ];
  return Feed::create($values);
}