function FeedParserTest::testRedirectFeed

Same name and namespace in other branches
  1. 8.9.x 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 101

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

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