You are here

public function AggregatorTestBase::getFeedEditObject in Drupal 8

Same name in this branch
  1. 8 core/modules/aggregator/src/Tests/AggregatorTestBase.php \Drupal\aggregator\Tests\AggregatorTestBase::getFeedEditObject()
  2. 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/src/Tests/AggregatorTestBase.php, line 142

Class

AggregatorTestBase
Defines a base class for testing the Aggregator module.

Namespace

Drupal\aggregator\Tests

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);
}