Commit c393119b authored by alexpott's avatar alexpott

Issue #2348773 by geertvd, IT-Cru: Aggregator item counts are formatted as date intervals

parent 1ed3c6f1
......@@ -124,7 +124,7 @@ public function adminOverview() {
foreach ($feeds as $feed) {
$row = array();
$row[] = $feed->link();
$row[] = $this->dateFormatter->formatInterval($entity_manager->getStorage('aggregator_item')->getItemCount($feed), '1 item', '@count items');
$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->formatInterval(REQUEST_TIME - $last_checked))) : $this->t('never'));
......
......@@ -124,7 +124,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
$info = $this->getPluginDefinition();
$counts = array(3, 5, 10, 15, 20, 25);
$items = array_map(function ($count) {
return $this->dateFormatter->formatInterval($count, '1 item', '@count items');
return $this->formatPlural($count, '1 item', '@count items');
}, array_combine($counts, $counts));
$intervals = array(3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200, 4838400, 9676800);
$period = array_map(array($this->dateFormatter, 'formatInterval'), array_combine($intervals, $intervals));
......
......@@ -2,17 +2,18 @@
/**
* @file
* Definition of Drupal\aggregator\Tests\AggregatorConfigurationTest.
* Contains \Drupal\aggregator\Tests\AggregatorAdminTest.
*/
namespace Drupal\aggregator\Tests;
/**
* Tests aggregator settings page.
* Tests aggregator admin pages.
*
* @group aggregator
*/
class AggregatorConfigurationTest extends AggregatorTestBase {
class AggregatorAdminTest extends AggregatorTestBase {
/**
* Tests the settings form to ensure the correct default values are used.
*/
......@@ -59,4 +60,29 @@ public function testSettingsPage() {
$this->drupalGet('admin/config/services/aggregator/settings');
$this->assertResponse(200);
}
/**
* Tests the overview page.
*/
function testOverviewPage() {
$feed = $this->createFeed($this->getRSS091Sample());
$this->drupalGet('admin/config/services/aggregator');
$result = $this->xpath('//table/tbody/tr');
// Check if the amount of feeds in the overview matches the amount created.
$this->assertEqual(1, count($result), 'Created feed is found in the overview');
// Check if the fields in the table match with what's expected.
$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]);
// Update the items of the first feed.
$feed->refreshItems();
$this->drupalGet('admin/config/services/aggregator');
$result = $this->xpath('//table/tbody/tr');
// Check if the fields in the table match with what's expected.
$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]);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment