Mercurial > hg > cmmr2012-drupal-site
diff core/modules/datetime/tests/src/Functional/DateTimeFieldTest.php @ 5:12f9dff5fda9 tip
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:34:47 +0100 |
parents | a9cd425dd02b |
children |
line wrap: on
line diff
--- a/core/modules/datetime/tests/src/Functional/DateTimeFieldTest.php Thu Feb 28 13:11:55 2019 +0000 +++ b/core/modules/datetime/tests/src/Functional/DateTimeFieldTest.php Thu May 09 15:34:47 2019 +0100 @@ -113,8 +113,10 @@ case 'format_type': // Verify that a date is displayed. Since this is a date-only // field, it is expected to display the time as 00:00:00. - $expected = format_date($date->getTimestamp(), $new_value, '', DateTimeItemInterface::STORAGE_TIMEZONE); - $expected_iso = format_date($date->getTimestamp(), 'custom', 'Y-m-d\TH:i:s\Z', DateTimeItemInterface::STORAGE_TIMEZONE); + /** @var \Drupal\Core\Datetime\DateFormatterInterface $date_formatter */ + $date_formatter = $this->container->get('date.formatter'); + $expected = $date_formatter->format($date->getTimestamp(), $new_value, '', DateTimeItemInterface::STORAGE_TIMEZONE); + $expected_iso = $date_formatter->format($date->getTimestamp(), 'custom', 'Y-m-d\TH:i:s\Z', DateTimeItemInterface::STORAGE_TIMEZONE); $output = $this->renderTestEntity($id); $expected_markup = '<time datetime="' . $expected_iso . '" class="datetime">' . $expected . '</time>'; $this->assertContains($expected_markup, $output, new FormattableMarkup('Formatted date field using %value format displayed as %expected with %expected_iso attribute in %timezone.', [ @@ -279,8 +281,9 @@ switch ($setting) { case 'format_type': // Verify that a date is displayed. - $expected = format_date($date->getTimestamp(), $new_value); - $expected_iso = format_date($date->getTimestamp(), 'custom', 'Y-m-d\TH:i:s\Z', 'UTC'); + $date_formatter = $this->container->get('date.formatter'); + $expected = $date_formatter->format($date->getTimestamp(), $new_value); + $expected_iso = $date_formatter->format($date->getTimestamp(), 'custom', 'Y-m-d\TH:i:s\Z', 'UTC'); $output = $this->renderTestEntity($id); $expected_markup = '<time datetime="' . $expected_iso . '" class="datetime">' . $expected . '</time>'; $this->assertContains($expected_markup, $output, new FormattableMarkup('Formatted date field using %value format displayed as %expected with %expected_iso attribute.', ['%value' => $new_value, '%expected' => $expected, '%expected_iso' => $expected_iso]));