function FeedParserTest::testInvalidFeed

Same name in other branches
  1. 9 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 107

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(t('Update items'));
    $this->assertRaw(t('The feed from %title seems to be broken because of error', [
        '%title' => $feed->label(),
    ]));
}

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