Commit 0c0481ef authored by alexpott's avatar alexpott

Revert "Issue #2780549 by andrewbelcher, alexpott, mpdonadio:...

Revert "Issue #2780549 by andrewbelcher, alexpott, mpdonadio: FormattedDateDiff::$maxAge never applied to caches"

This reverts commit abe69518.
parent abe69518
......@@ -51,9 +51,9 @@ public function getString() {
}
/**
* {@inheritdoc}
* @return int
*/
public function getCacheMaxAge() {
public function getMaxAge() {
return $this->maxAge;
}
......
......@@ -2,7 +2,6 @@
namespace Drupal\Tests\Core\Datetime;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Datetime\DateFormatter;
use Drupal\Core\Datetime\FormattedDateDiff;
use Drupal\Core\DependencyInjection\ContainerBuilder;
......@@ -393,36 +392,6 @@ public function providerTestFormatDiff() {
return $data;
}
/**
* Tests FormattedDateDiff.
*
* @covers \Drupal\Core\Datetime\FormattedDateDiff::toRenderable
* @covers \Drupal\Core\Datetime\FormattedDateDiff::getString
* @covers \Drupal\Core\Datetime\FormattedDateDiff::getCacheMaxAge
*/
public function testFormattedDateDiff() {
$string = '10 minutes';
$max_age = 60;
$object = new FormattedDateDiff($string, $max_age);
// Test conversion to a render array.
$expected = [
'#markup' => $string,
'#cache' => [
'max-age' => $max_age,
],
];
$this->assertArrayEquals($expected, $object->toRenderable());
// Test retrieving the formatted time difference string.
$this->assertEquals($string, $object->getString());
// Test applying cacheability data to an existing build.
$build = [];
CacheableMetadata::createFromObject($object)->applyTo($build);
$this->assertEquals($max_age, $build['#cache']['max-age']);
}
/**
* Creates a UNIX timestamp given a date and time string in the format
* year-month-day hour:minute:seconds (e.g. 2013-12-11 10:09:08).
......
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