summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2016-08-12 19:43:12 (GMT)
committerAlex Pott2016-08-12 19:43:12 (GMT)
commit0c0481ef864353e674e5c1bcd1462412809c1bbe (patch)
tree6d64e20b087b8e970d49bf08f6c0a6a6a4ad9b2b
parentabe69518ab2bb8d19e395f7106afd3379cf48abd (diff)
Revert "Issue #2780549 by andrewbelcher, alexpott, mpdonadio: FormattedDateDiff::$maxAge never applied to caches"
This reverts commit abe69518ab2bb8d19e395f7106afd3379cf48abd.
-rw-r--r--core/lib/Drupal/Core/Datetime/FormattedDateDiff.php4
-rw-r--r--core/tests/Drupal/Tests/Core/Datetime/DateTest.php31
2 files changed, 2 insertions, 33 deletions
diff --git a/core/lib/Drupal/Core/Datetime/FormattedDateDiff.php b/core/lib/Drupal/Core/Datetime/FormattedDateDiff.php
index 1429812..07bb836 100644
--- a/core/lib/Drupal/Core/Datetime/FormattedDateDiff.php
+++ b/core/lib/Drupal/Core/Datetime/FormattedDateDiff.php
@@ -51,9 +51,9 @@ class FormattedDateDiff implements RenderableInterface, CacheableDependencyInter
}
/**
- * {@inheritdoc}
+ * @return int
*/
- public function getCacheMaxAge() {
+ public function getMaxAge() {
return $this->maxAge;
}
diff --git a/core/tests/Drupal/Tests/Core/Datetime/DateTest.php b/core/tests/Drupal/Tests/Core/Datetime/DateTest.php
index 192d22e..238b5c8 100644
--- a/core/tests/Drupal/Tests/Core/Datetime/DateTest.php
+++ b/core/tests/Drupal/Tests/Core/Datetime/DateTest.php
@@ -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;
@@ -394,36 +393,6 @@ class DateTest extends UnitTestCase {
}
/**
- * 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).
*