View source
<?php
namespace Drupal\aggregator\Tests;
class AggregatorAdminTest extends AggregatorTestBase {
public function testSettingsPage() {
$this
->drupalGet('admin/config');
$this
->clickLink('Feed aggregator');
$this
->clickLink('Settings');
$this
->assertText('Test fetcher');
$this
->assertText('Test parser');
$this
->assertText('Test processor');
$edit = array(
'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
->drupalPostForm('admin/config/services/aggregator/settings', $edit, t('Save configuration'));
$this
->assertText(t('The configuration options have been saved.'));
foreach ($edit as $name => $value) {
$this
->assertFieldByName($name, $value, format_string('"@name" has correct default value.', array(
'@name' => $name,
)));
}
$this
->assertText(t('Dummy length setting'));
$edit = array(
'dummy_length' => 100,
);
$this
->drupalPostForm('admin/config/services/aggregator/settings', $edit, t('Save configuration'));
$this
->assertText(t('The configuration options have been saved.'));
$this
->assertFieldByName('dummy_length', 100, '"dummy_length" has correct default value.');
$this->container
->get('module_installer')
->uninstall(array(
'aggregator_test',
));
$this
->resetAll();
$this
->drupalGet('admin/config/services/aggregator/settings');
$this
->assertResponse(200);
}
function testOverviewPage() {
$feed = $this
->createFeed($this
->getRSS091Sample());
$this
->drupalGet('admin/config/services/aggregator');
$result = $this
->xpath('//table/tbody/tr');
$this
->assertEqual(1, count($result), 'Created feed is found in the overview');
$this
->assertEqual($feed
->label(), (string) $result[0]->td[0]->a);
$count = $this->container
->get('entity.manager')
->getStorage('aggregator_item')
->getItemCount($feed);
$this
->assertEqual(\Drupal::translation()
->formatPlural($count, '1 item', '@count items'), (string) $result[0]->td[1]);
$feed
->refreshItems();
$this
->drupalGet('admin/config/services/aggregator');
$result = $this
->xpath('//table/tbody/tr');
$this
->assertEqual($feed
->label(), (string) $result[0]->td[0]->a);
$count = $this->container
->get('entity.manager')
->getStorage('aggregator_item')
->getItemCount($feed);
$this
->assertEqual(\Drupal::translation()
->formatPlural($count, '1 item', '@count items'), (string) $result[0]->td[1]);
}
}