Mercurial > hg > cmmr2012-drupal-site
comparison 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 |
comparison
equal
deleted
inserted
replaced
4:a9cd425dd02b | 5:12f9dff5fda9 |
---|---|
111 $this->renderTestEntity($id); | 111 $this->renderTestEntity($id); |
112 switch ($setting) { | 112 switch ($setting) { |
113 case 'format_type': | 113 case 'format_type': |
114 // Verify that a date is displayed. Since this is a date-only | 114 // Verify that a date is displayed. Since this is a date-only |
115 // field, it is expected to display the time as 00:00:00. | 115 // field, it is expected to display the time as 00:00:00. |
116 $expected = format_date($date->getTimestamp(), $new_value, '', DateTimeItemInterface::STORAGE_TIMEZONE); | 116 /** @var \Drupal\Core\Datetime\DateFormatterInterface $date_formatter */ |
117 $expected_iso = format_date($date->getTimestamp(), 'custom', 'Y-m-d\TH:i:s\Z', DateTimeItemInterface::STORAGE_TIMEZONE); | 117 $date_formatter = $this->container->get('date.formatter'); |
118 $expected = $date_formatter->format($date->getTimestamp(), $new_value, '', DateTimeItemInterface::STORAGE_TIMEZONE); | |
119 $expected_iso = $date_formatter->format($date->getTimestamp(), 'custom', 'Y-m-d\TH:i:s\Z', DateTimeItemInterface::STORAGE_TIMEZONE); | |
118 $output = $this->renderTestEntity($id); | 120 $output = $this->renderTestEntity($id); |
119 $expected_markup = '<time datetime="' . $expected_iso . '" class="datetime">' . $expected . '</time>'; | 121 $expected_markup = '<time datetime="' . $expected_iso . '" class="datetime">' . $expected . '</time>'; |
120 $this->assertContains($expected_markup, $output, new FormattableMarkup('Formatted date field using %value format displayed as %expected with %expected_iso attribute in %timezone.', [ | 122 $this->assertContains($expected_markup, $output, new FormattableMarkup('Formatted date field using %value format displayed as %expected with %expected_iso attribute in %timezone.', [ |
121 '%value' => $new_value, | 123 '%value' => $new_value, |
122 '%expected' => $expected, | 124 '%expected' => $expected, |
277 | 279 |
278 $this->renderTestEntity($id); | 280 $this->renderTestEntity($id); |
279 switch ($setting) { | 281 switch ($setting) { |
280 case 'format_type': | 282 case 'format_type': |
281 // Verify that a date is displayed. | 283 // Verify that a date is displayed. |
282 $expected = format_date($date->getTimestamp(), $new_value); | 284 $date_formatter = $this->container->get('date.formatter'); |
283 $expected_iso = format_date($date->getTimestamp(), 'custom', 'Y-m-d\TH:i:s\Z', 'UTC'); | 285 $expected = $date_formatter->format($date->getTimestamp(), $new_value); |
286 $expected_iso = $date_formatter->format($date->getTimestamp(), 'custom', 'Y-m-d\TH:i:s\Z', 'UTC'); | |
284 $output = $this->renderTestEntity($id); | 287 $output = $this->renderTestEntity($id); |
285 $expected_markup = '<time datetime="' . $expected_iso . '" class="datetime">' . $expected . '</time>'; | 288 $expected_markup = '<time datetime="' . $expected_iso . '" class="datetime">' . $expected . '</time>'; |
286 $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])); | 289 $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])); |
287 break; | 290 break; |
288 } | 291 } |