Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
c393119b
Commit
c393119b
authored
Mar 20, 2015
by
Alex Pott
Browse files
Issue
#2348773
by geertvd, IT-Cru: Aggregator item counts are formatted as date intervals
parent
1ed3c6f1
Changes
3
Hide whitespace changes
Inline
Side-by-side
core/modules/aggregator/src/Controller/AggregatorController.php
View file @
c393119b
...
...
@@ -124,7 +124,7 @@ public function adminOverview() {
foreach
(
$feeds
as
$feed
)
{
$row
=
array
();
$row
[]
=
$feed
->
link
();
$row
[]
=
$this
->
dateFormatter
->
formatInterv
al
(
$entity_manager
->
getStorage
(
'aggregator_item'
)
->
getItemCount
(
$feed
),
'1 item'
,
'@count items'
);
$row
[]
=
$this
->
formatPlur
al
(
$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'
));
...
...
core/modules/aggregator/src/Plugin/aggregator/processor/DefaultProcessor.php
View file @
c393119b
...
...
@@ -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
->
formatInterv
al
(
$count
,
'1 item'
,
'@count items'
);
return
$this
->
formatPlur
al
(
$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
));
...
...
core/modules/aggregator/src/Tests/Aggregator
Configuratio
nTest.php
→
core/modules/aggregator/src/Tests/Aggregator
Admi
nTest.php
View file @
c393119b
...
...
@@ -2,17 +2,18 @@
/**
* @file
*
Definition of
Drupal\aggregator\Tests\Aggregator
Configuratio
nTest.
*
Contains \
Drupal\aggregator\Tests\Aggregator
Admi
nTest.
*/
namespace
Drupal\aggregator\Tests
;
/**
* Tests aggregator
settings
page.
* Tests aggregator
admin
page
s
.
*
* @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
]);
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment