summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2015-08-18 15:40:52 +0100
committerAlex Pott2015-08-18 15:40:52 +0100
commit12b8a2f7798eefd1c870bd05050e95c793ea7042 (patch)
tree1c66b60b888a508cbfca077b37d93f4e6993fee5
parent0d25892414200c352aa0c9c354cde427952a92be (diff)
Issue #2228823 by StryKaizer, ParisLiakos, joshi.rohit100, Nitesh Sethia, Aron Novak, geertvd: Aggregator feed overview misleading text
-rw-r--r--core/modules/aggregator/src/Controller/AggregatorController.php14
-rw-r--r--core/modules/aggregator/src/Tests/FeedAdminDisplayTest.php67
2 files changed, 79 insertions, 2 deletions
diff --git a/core/modules/aggregator/src/Controller/AggregatorController.php b/core/modules/aggregator/src/Controller/AggregatorController.php
index 13ff3d9..1b3b997 100644
--- a/core/modules/aggregator/src/Controller/AggregatorController.php
+++ b/core/modules/aggregator/src/Controller/AggregatorController.php
@@ -127,8 +127,18 @@ class AggregatorController extends ControllerBase {
$row[] = $this->formatPlural($entity_manager->getStorage('aggregator_item')->getItemCount($feed), '1 item', '@count items');
$last_checked = $feed->getLastCheckedTime();
$refresh_rate = $feed->getRefreshRate();
- $row[] = ($last_checked ? $this->t('@time ago', array('@time' => $this->dateFormatter->formatTimeDiffSince($last_checked))) : $this->t('never'));
- $row[] = ($last_checked && $refresh_rate ? $this->t('@time left', array('@time' => $this->dateFormatter->formatTimeDiffUntil($last_checked + $refresh_rate))) : $this->t('never'));
+
+ $row[] = ($last_checked ? $this->t('@time ago', array('@time' => $this->dateFormatter->formatInterval(REQUEST_TIME - $last_checked))) : $this->t('never'));
+ if (!$last_checked && $refresh_rate) {
+ $next_update = $this->t('imminently');
+ }
+ elseif ($last_checked && $refresh_rate) {
+ $next_update = $next = $this->t('%time left', array('%time' => $this->dateFormatter->formatInterval($last_checked + $refresh_rate - REQUEST_TIME)));
+ }
+ else {
+ $next_update = $this->t('never');
+ }
+ $row[] = $next_update;
$links['edit'] = [
'title' => $this->t('Edit'),
'url' => Url::fromRoute('entity.aggregator_feed.edit_form', ['aggregator_feed' => $feed->id()]),
diff --git a/core/modules/aggregator/src/Tests/FeedAdminDisplayTest.php b/core/modules/aggregator/src/Tests/FeedAdminDisplayTest.php
new file mode 100644
index 0000000..dee35eb
--- /dev/null
+++ b/core/modules/aggregator/src/Tests/FeedAdminDisplayTest.php
@@ -0,0 +1,67 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\aggregator\Tests\FeedAdminDisplayTest.
+ */
+
+namespace Drupal\aggregator\Tests;
+
+/**
+ * Tests the display of a feed on the feed aggregator list page.
+ *
+ * @group aggregator
+ */
+class FeedAdminDisplayTest extends AggregatorTestBase {
+
+ /**
+ * Tests the "Next update" and "Last update" fields.
+ */
+ public function testFeedUpdateFields() {
+ // Create scheduled feed.
+ $scheduled_feed = $this->createFeed(NULL, array('refresh' => '900'));
+
+ $this->drupalGet('admin/config/services/aggregator');
+ $this->assertResponse(200, 'Aggregator feed overview page exists.');
+
+ // The scheduled feed shows that it has not been updated yet and is
+ // scheduled.
+ $this->assertText('never', 'The scheduled feed has not been updated yet. Last update shows "never".');
+ $this->assertText('imminently', 'The scheduled feed has not been updated yet. Next update shows "imminently".');
+ $this->assertNoText('ago', 'The scheduled feed has not been updated yet. Last update does not show "x x ago".');
+ $this->assertNoText('left', 'The scheduled feed has not been updated yet. Next update does not show "x x left".');
+
+ $this->updateFeedItems($scheduled_feed);
+ $this->drupalGet('admin/config/services/aggregator');
+
+ // After the update, an interval should be displayed on both last updated
+ // and next update.
+ $this->assertNoText('never', 'The scheduled feed has been updated. Last updated changed.');
+ $this->assertNoText('imminently', 'The scheduled feed has been updated. Next update changed.');
+ $this->assertText('ago', 'The scheduled feed been updated. Last update shows "x x ago".');
+ $this->assertText('left', 'The scheduled feed has been updated. Next update shows "x x left".');
+
+ // Delete scheduled feed.
+ $this->deleteFeed($scheduled_feed);
+
+ // Create non-scheduled feed.
+ $non_scheduled_feed = $this->createFeed(NULL, array('refresh' => '0'));
+
+ $this->drupalGet('admin/config/services/aggregator');
+ // The non scheduled feed shows that it has not been updated yet.
+ $this->assertText('never', 'The non scheduled feed has not been updated yet. Last update shows "never".');
+ $this->assertNoText('imminently', 'The non scheduled feed does not show "imminently" as next update.');
+ $this->assertNoText('ago', 'The non scheduled feed has not been updated. It does not show "x x ago" as last update.');
+ $this->assertNoText('left', 'The feed is not scheduled. It does not show a timeframe "x x left" for next update.');
+
+ $this->updateFeedItems($non_scheduled_feed);
+ $this->drupalGet('admin/config/services/aggregator');
+
+ // After the feed update, we still need to see "never" as next update label.
+ // Last update will show an interval.
+ $this->assertNoText('imminently', 'The updated non scheduled feed does not show "imminently" as next update.');
+ $this->assertText('never', 'The updated non scheduled feed still shows "never" as next update.');
+ $this->assertText('ago', 'The non scheduled feed has been updated. It shows "x x ago" as last update.');
+ $this->assertNoText('left', 'The feed is not scheduled. It does not show a timeframe "x x left" for next update.');
+ }
+}