public function AddFeedTest::testAddFeed in Drupal 9
Same name and namespace in other branches
- 8 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
->assertSession()
->addressEquals(Url::fromRoute('aggregator.feed_add'));
$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);
// Verify that the feed label is present in the page title.
$this
->assertSession()
->pageTextContains($feed
->label());
$this
->assertSession()
->pageTextContains($feed
->getWebsiteUrl());
// Try to add a duplicate.
$edit = [
'title[0][value]' => $feed
->label(),
'url[0][value]' => $feed
->getUrl(),
'refresh' => '900',
];
$this
->drupalGet('aggregator/sources/add');
$this
->submitForm($edit, 'Save');
$this
->assertSession()
->pageTextContains('A feed named ' . $feed
->label() . ' already exists. Enter a unique title.');
$this
->assertSession()
->pageTextContains('A feed with this URL ' . $feed
->getUrl() . ' already exists. Enter a unique URL.');
// Delete feed.
$this
->deleteFeed($feed);
}