You are here

public function FeedParserTest::testRedirectFeed in Drupal 9

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

Tests that a redirected feed is tracked to its target.

File

core/modules/aggregator/tests/src/Functional/FeedParserTest.php, line 100

Class

FeedParserTest
Tests the built-in feed parser with valid feed samples.

Namespace

Drupal\Tests\aggregator\Functional

Code

public function testRedirectFeed() {
  $redirect_url = Url::fromRoute('aggregator_test.redirect')
    ->setAbsolute()
    ->toString();
  $feed = Feed::create([
    'url' => $redirect_url,
    'title' => $this
      ->randomMachineName(),
  ]);
  $feed
    ->save();
  $feed
    ->refreshItems();

  // Make sure that the feed URL was updated correctly.
  $this
    ->assertEquals(Url::fromRoute('aggregator_test.feed', [], [
    'absolute' => TRUE,
  ])
    ->toString(), $feed
    ->getUrl());
}