function FeedParserTest::testInvalidFeed

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

Tests error handling when an invalid feed is added.

File

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

Class

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

Namespace

Drupal\Tests\aggregator\Functional

Code

public function testInvalidFeed() {
    // Simulate a typo in the URL to force a curl exception.
    $invalid_url = 'http:/www.drupal.org';
    $feed = Feed::create([
        'url' => $invalid_url,
        'title' => $this->randomMachineName(),
    ]);
    $feed->save();
    // Update the feed. Use the UI to be able to check the message easily.
    $this->drupalGet('admin/config/services/aggregator');
    $this->clickLink('Update items');
    $this->assertSession()
        ->pageTextContains('The feed from ' . $feed->label() . ' seems to be broken because of error');
}

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