3 namespace Drupal\Tests\aggregator\Functional;
6 * Tests aggregator admin pages.
10 class AggregatorAdminTest extends AggregatorTestBase {
13 * Tests the settings form to ensure the correct default values are used.
15 public function testSettingsPage() {
16 $this->drupalGet('admin/config');
17 $this->clickLink('Aggregator');
18 $this->clickLink('Settings');
19 // Make sure that test plugins are present.
20 $this->assertText('Test fetcher');
21 $this->assertText('Test parser');
22 $this->assertText('Test processor');
24 // Set new values and enable test plugins.
26 'aggregator_allowed_html_tags' => '<a>',
27 'aggregator_summary_items' => 10,
28 'aggregator_clear' => 3600,
29 'aggregator_teaser_length' => 200,
30 'aggregator_fetcher' => 'aggregator_test_fetcher',
31 'aggregator_parser' => 'aggregator_test_parser',
32 'aggregator_processors[aggregator_test_processor]' => 'aggregator_test_processor',
34 $this->drupalPostForm('admin/config/services/aggregator/settings', $edit, t('Save configuration'));
35 $this->assertText(t('The configuration options have been saved.'));
37 foreach ($edit as $name => $value) {
38 $this->assertFieldByName($name, $value, format_string('"@name" has correct default value.', ['@name' => $name]));
41 // Check for our test processor settings form.
42 $this->assertText(t('Dummy length setting'));
43 // Change its value to ensure that settingsSubmit is called.
45 'dummy_length' => 100,
47 $this->drupalPostForm('admin/config/services/aggregator/settings', $edit, t('Save configuration'));
48 $this->assertText(t('The configuration options have been saved.'));
49 $this->assertFieldByName('dummy_length', 100, '"dummy_length" has correct default value.');
51 // Make sure settings form is still accessible even after uninstalling a module
52 // that provides the selected plugins.
53 $this->container->get('module_installer')->uninstall(['aggregator_test']);
55 $this->drupalGet('admin/config/services/aggregator/settings');
56 $this->assertResponse(200);
60 * Tests the overview page.
62 public function testOverviewPage() {
63 $feed = $this->createFeed($this->getRSS091Sample());
64 $this->drupalGet('admin/config/services/aggregator');
66 $result = $this->xpath('//table/tbody/tr');
67 // Check if the amount of feeds in the overview matches the amount created.
68 $this->assertEqual(1, count($result), 'Created feed is found in the overview');
69 // Check if the fields in the table match with what's expected.
70 $link = $this->xpath('//table/tbody/tr//td[1]/a');
71 $this->assertEquals($feed->label(), $link[0]->getText());
72 $count = $this->container->get('entity.manager')->getStorage('aggregator_item')->getItemCount($feed);
73 $td = $this->xpath('//table/tbody/tr//td[2]');
74 $this->assertEquals(\Drupal::translation()->formatPlural($count, '1 item', '@count items'), $td[0]->getText());
76 // Update the items of the first feed.
77 $feed->refreshItems();
78 $this->drupalGet('admin/config/services/aggregator');
79 $result = $this->xpath('//table/tbody/tr');
80 // Check if the fields in the table match with what's expected.
81 $link = $this->xpath('//table/tbody/tr//td[1]/a');
82 $this->assertEquals($feed->label(), $link[0]->getText());
83 $count = $this->container->get('entity.manager')->getStorage('aggregator_item')->getItemCount($feed);
84 $td = $this->xpath('//table/tbody/tr//td[2]');
85 $this->assertEquals(\Drupal::translation()->formatPlural($count, '1 item', '@count items'), $td[0]->getText());