function AddFeedTest::testAddFeed
Same name in other branches
- 9 core/modules/aggregator/tests/src/Functional/AddFeedTest.php \Drupal\Tests\aggregator\Functional\AddFeedTest::testAddFeed()
Creates and ensures that a feed is unique, checks source, and deletes feed.
File
-
core/
modules/ aggregator/ tests/ src/ Functional/ AddFeedTest.php, line 28
Class
- AddFeedTest
- Add feed test.
Namespace
Drupal\Tests\aggregator\FunctionalCode
public function testAddFeed() {
$feed = $this->createFeed();
$feed->refreshItems();
// Check feed data.
$this->assertUrl(Url::fromRoute('aggregator.feed_add', [], [
'absolute' => TRUE,
])->toString(), [], 'Directed to correct URL.');
$this->assertTrue($this->uniqueFeed($feed->label(), $feed->getUrl()), 'The feed is unique.');
// Check feed source.
$this->drupalGet('aggregator/sources/' . $feed->id());
$this->assertSession()
->statusCodeEquals(200);
$this->assertText($feed->label(), 'Page title');
$this->assertRaw($feed->getWebsiteUrl());
// Try to add a duplicate.
$edit = [
'title[0][value]' => $feed->label(),
'url[0][value]' => $feed->getUrl(),
'refresh' => '900',
];
$this->drupalPostForm('aggregator/sources/add', $edit, t('Save'));
$this->assertRaw(t('A feed named %feed already exists. Enter a unique title.', [
'%feed' => $feed->label(),
]));
$this->assertRaw(t('A feed with this URL %url already exists. Enter a unique URL.', [
'%url' => $feed->getUrl(),
]));
// Delete feed.
$this->deleteFeed($feed);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.