3 namespace Drupal\aggregator\Tests;
6 * Tests the display of a feed on the Aggregator list page.
10 class FeedAdminDisplayTest extends AggregatorTestBase {
13 * Tests the "Next update" and "Last update" fields.
15 public function testFeedUpdateFields() {
16 // Create scheduled feed.
17 $scheduled_feed = $this->createFeed(NULL, ['refresh' => '900']);
19 $this->drupalGet('admin/config/services/aggregator');
20 $this->assertResponse(200, 'Aggregator feed overview page exists.');
22 // The scheduled feed shows that it has not been updated yet and is
24 $this->assertText('never', 'The scheduled feed has not been updated yet. Last update shows "never".');
25 $this->assertText('imminently', 'The scheduled feed has not been updated yet. Next update shows "imminently".');
26 $this->assertNoText('ago', 'The scheduled feed has not been updated yet. Last update does not show "x x ago".');
27 $this->assertNoText('left', 'The scheduled feed has not been updated yet. Next update does not show "x x left".');
29 $this->updateFeedItems($scheduled_feed);
30 $this->drupalGet('admin/config/services/aggregator');
32 // After the update, an interval should be displayed on both last updated
34 $this->assertNoText('never', 'The scheduled feed has been updated. Last updated changed.');
35 $this->assertNoText('imminently', 'The scheduled feed has been updated. Next update changed.');
36 $this->assertText('ago', 'The scheduled feed been updated. Last update shows "x x ago".');
37 $this->assertText('left', 'The scheduled feed has been updated. Next update shows "x x left".');
39 // Delete scheduled feed.
40 $this->deleteFeed($scheduled_feed);
42 // Create non-scheduled feed.
43 $non_scheduled_feed = $this->createFeed(NULL, ['refresh' => '0']);
45 $this->drupalGet('admin/config/services/aggregator');
46 // The non scheduled feed shows that it has not been updated yet.
47 $this->assertText('never', 'The non scheduled feed has not been updated yet. Last update shows "never".');
48 $this->assertNoText('imminently', 'The non scheduled feed does not show "imminently" as next update.');
49 $this->assertNoText('ago', 'The non scheduled feed has not been updated. It does not show "x x ago" as last update.');
50 $this->assertNoText('left', 'The feed is not scheduled. It does not show a timeframe "x x left" for next update.');
52 $this->updateFeedItems($non_scheduled_feed);
53 $this->drupalGet('admin/config/services/aggregator');
55 // After the feed update, we still need to see "never" as next update label.
56 // Last update will show an interval.
57 $this->assertNoText('imminently', 'The updated non scheduled feed does not show "imminently" as next update.');
58 $this->assertText('never', 'The updated non scheduled feed still shows "never" as next update.');
59 $this->assertText('ago', 'The non scheduled feed has been updated. It shows "x x ago" as last update.');
60 $this->assertNoText('left', 'The feed is not scheduled. It does not show a timeframe "x x left" for next update.');
66 public function randomMachineName($length = 8) {
67 $value = parent::randomMachineName($length);
68 // See expected values in testFeedUpdateFields().
69 $value = str_replace(['never', 'imminently', 'ago', 'left'], 'x', $value);