Backup of db before drupal security update
[yaffs-website] / web / core / modules / aggregator / src / Tests / FeedAdminDisplayTest.php
1 <?php
2
3 namespace Drupal\aggregator\Tests;
4
5 /**
6  * Tests the display of a feed on the Aggregator list page.
7  *
8  * @group aggregator
9  */
10 class FeedAdminDisplayTest extends AggregatorTestBase {
11
12   /**
13    * Tests the "Next update" and "Last update" fields.
14    */
15   public function testFeedUpdateFields() {
16     // Create scheduled feed.
17     $scheduled_feed = $this->createFeed(NULL, ['refresh' => '900']);
18
19     $this->drupalGet('admin/config/services/aggregator');
20     $this->assertResponse(200, 'Aggregator feed overview page exists.');
21
22     // The scheduled feed shows that it has not been updated yet and is
23     // scheduled.
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".');
28
29     $this->updateFeedItems($scheduled_feed);
30     $this->drupalGet('admin/config/services/aggregator');
31
32     // After the update, an interval should be displayed on both last updated
33     // and next update.
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".');
38
39     // Delete scheduled feed.
40     $this->deleteFeed($scheduled_feed);
41
42     // Create non-scheduled feed.
43     $non_scheduled_feed = $this->createFeed(NULL, ['refresh' => '0']);
44
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.');
51
52     $this->updateFeedItems($non_scheduled_feed);
53     $this->drupalGet('admin/config/services/aggregator');
54
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.');
61   }
62
63   /**
64    * {@inheritdoc}
65    */
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);
70     return $value;
71   }
72
73 }