View source
<?php
namespace Drupal\Tests\aggregator\Functional;
class AggregatorAdminTest extends AggregatorTestBase {
protected $defaultTheme = 'stark';
public function testSettingsPage() {
$this
->drupalGet('admin/config');
$this
->clickLink('Aggregator');
$this
->clickLink('Settings');
$this
->assertSession()
->pageTextContains('Test fetcher');
$this
->assertSession()
->pageTextContains('Test parser');
$this
->assertSession()
->pageTextContains('Test processor');
$edit = [
'aggregator_allowed_html_tags' => '<a>',
'aggregator_summary_items' => 10,
'aggregator_clear' => 3600,
'aggregator_teaser_length' => 200,
'aggregator_fetcher' => 'aggregator_test_fetcher',
'aggregator_parser' => 'aggregator_test_parser',
'aggregator_processors[aggregator_test_processor]' => 'aggregator_test_processor',
];
$this
->drupalGet('admin/config/services/aggregator/settings');
$this
->submitForm($edit, 'Save configuration');
$this
->assertSession()
->pageTextContains('The configuration options have been saved.');
foreach ($edit as $name => $value) {
$this
->assertSession()
->fieldValueEquals($name, $value);
}
$this
->assertSession()
->pageTextContains('Dummy length setting');
$edit = [
'dummy_length' => 100,
];
$this
->drupalGet('admin/config/services/aggregator/settings');
$this
->submitForm($edit, 'Save configuration');
$this
->assertSession()
->pageTextContains('The configuration options have been saved.');
$this
->assertSession()
->fieldValueEquals('dummy_length', 100);
$this->container
->get('module_installer')
->uninstall([
'aggregator_test',
]);
$this
->resetAll();
$this
->drupalGet('admin/config/services/aggregator/settings');
$this
->assertSession()
->statusCodeEquals(200);
}
public function testOverviewPage() {
$feed = $this
->createFeed($this
->getRSS091Sample());
$this
->drupalGet('admin/config/services/aggregator');
$this
->assertSession()
->elementsCount('xpath', '//table/tbody/tr', 1);
$this
->assertSession()
->elementTextContains('xpath', '//table/tbody/tr//td[1]/a', $feed
->label());
$count = $this->container
->get('entity_type.manager')
->getStorage('aggregator_item')
->getItemCount($feed);
$this
->assertSession()
->elementTextContains('xpath', '//table/tbody/tr//td[2]', \Drupal::translation()
->formatPlural($count, '1 item', '@count items'));
$feed
->refreshItems();
$this
->drupalGet('admin/config/services/aggregator');
$this
->assertSession()
->elementsCount('xpath', '//table/tbody/tr', 1);
$this
->assertSession()
->elementTextContains('xpath', '//table/tbody/tr//td[1]/a', $feed
->label());
$count = $this->container
->get('entity_type.manager')
->getStorage('aggregator_item')
->getItemCount($feed);
$this
->assertSession()
->elementTextContains('xpath', '//table/tbody/tr//td[2]', \Drupal::translation()
->formatPlural($count, '1 item', '@count items'));
}
}