UpdateFeedTest.php in Drupal 8
File
core/modules/aggregator/tests/src/Functional/UpdateFeedTest.php
View source
<?php
namespace Drupal\Tests\aggregator\Functional;
use Drupal\Component\Render\FormattableMarkup;
class UpdateFeedTest extends AggregatorTestBase {
protected $defaultTheme = 'stark';
public function testUpdateFeed() {
$remaining_fields = [
'title[0][value]',
'url[0][value]',
'',
];
foreach ($remaining_fields as $same_field) {
$feed = $this
->createFeed();
$edit = $this
->getFeedEditArray();
$edit['refresh'] = 1800;
if (isset($feed->{$same_field}->value)) {
$edit[$same_field] = $feed->{$same_field}->value;
}
$this
->drupalPostForm('aggregator/sources/' . $feed
->id() . '/configure', $edit, t('Save'));
$this
->assertText(t('The feed @name has been updated.', [
'@name' => $edit['title[0][value]'],
]), new FormattableMarkup('The feed %name has been updated.', [
'%name' => $edit['title[0][value]'],
]));
$view_link = $this
->xpath('//div[@class="messages"]//a[contains(@href, :href)]', [
':href' => 'aggregator/sources/',
]);
$this
->assert(isset($view_link), 'The message area contains a link to a feed');
$this
->assertUrl($feed
->toUrl('canonical', [
'absolute' => TRUE,
])
->toString());
$this
->assertTrue($this
->uniqueFeed($edit['title[0][value]'], $edit['url[0][value]']), 'The feed is unique.');
$this
->drupalGet('aggregator/sources/' . $feed
->id());
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertText($edit['title[0][value]'], 'Page title');
$feed->title = $edit['title[0][value]'];
$this
->deleteFeed($feed);
}
}
}