diff --git a/core/modules/system/src/Tests/Common/FormatDateTest.php b/core/modules/system/src/Tests/Common/FormatDateTest.php
index 36589ef..cddf0a3 100644
--- a/core/modules/system/src/Tests/Common/FormatDateTest.php
+++ b/core/modules/system/src/Tests/Common/FormatDateTest.php
@@ -77,46 +77,4 @@ function testAdminDefinedFormatDate() {
$this->assertIdentical(format_date($timestamp, 'undefined_style'), format_date($timestamp, 'fallback'), 'Test format_date() defaulting to `fallback` when $type not found.');
}
- /**
- * Tests the format_date() function.
- */
- function testFormatDate() {
- $timestamp = strtotime('2007-03-26T00:00:00+00:00');
- $this->assertIdentical(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T', 'America/Los_Angeles', 'en'), 'Sunday, 25-Mar-07 17:00:00 PDT', 'Test all parameters.');
- $this->assertIdentical(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T', 'America/Los_Angeles', self::LANGCODE), 'domingo, 25-Mar-07 17:00:00 PDT', 'Test translated format.');
- $this->assertIdentical(format_date($timestamp, 'custom', '\\l, d-M-y H:i:s T', 'America/Los_Angeles', self::LANGCODE), 'l, 25-Mar-07 17:00:00 PDT', 'Test an escaped format string.');
- $this->assertIdentical(format_date($timestamp, 'custom', '\\\\l, d-M-y H:i:s T', 'America/Los_Angeles', self::LANGCODE), '\\domingo, 25-Mar-07 17:00:00 PDT', 'Test format containing backslash character.');
- $this->assertIdentical(format_date($timestamp, 'custom', '\\\\\\l, d-M-y H:i:s T', 'America/Los_Angeles', self::LANGCODE), '\\l, 25-Mar-07 17:00:00 PDT', 'Test format containing backslash followed by escaped format string.');
- $this->assertIdentical(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T', 'Europe/London', 'en'), 'Monday, 26-Mar-07 01:00:00 BST', 'Test a different time zone.');
-
- // Change the default language and timezone.
- $this->config('system.site')->set('default_langcode', static::LANGCODE)->save();
- date_default_timezone_set('America/Los_Angeles');
-
- // Reset the language manager so new negotiations attempts will fall back on
- // on the new language.
- $this->container->get('language_manager')->reset();
-
- $this->assertIdentical(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T', 'America/Los_Angeles', 'en'), 'Sunday, 25-Mar-07 17:00:00 PDT', 'Test a different language.');
- $this->assertIdentical(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T', 'Europe/London'), 'Monday, 26-Mar-07 01:00:00 BST', 'Test a different time zone.');
- $this->assertIdentical(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T'), 'domingo, 25-Mar-07 17:00:00 PDT', 'Test custom date format.');
- $this->assertIdentical(format_date($timestamp, 'long'), 'domingo, 25. marzo 2007 - 17:00', 'Test long date format.');
- $this->assertIdentical(format_date($timestamp, 'medium'), '25. marzo 2007 - 17:00', 'Test medium date format.');
- $this->assertIdentical(format_date($timestamp, 'short'), '2007 Mar 25 - 5:00pm', 'Test short date format.');
- $this->assertIdentical(format_date($timestamp), '25. marzo 2007 - 17:00', 'Test default date format.');
- // Test HTML time element formats.
- $this->assertIdentical(format_date($timestamp, 'html_datetime'), '2007-03-25T17:00:00-0700', 'Test html_datetime date format.');
- $this->assertIdentical(format_date($timestamp, 'html_date'), '2007-03-25', 'Test html_date date format.');
- $this->assertIdentical(format_date($timestamp, 'html_time'), '17:00:00', 'Test html_time date format.');
- $this->assertIdentical(format_date($timestamp, 'html_yearless_date'), '03-25', 'Test html_yearless_date date format.');
- $this->assertIdentical(format_date($timestamp, 'html_week'), '2007-W12', 'Test html_week date format.');
- $this->assertIdentical(format_date($timestamp, 'html_month'), '2007-03', 'Test html_month date format.');
- $this->assertIdentical(format_date($timestamp, 'html_year'), '2007', 'Test html_year date format.');
-
- // HTML is not escaped by the date formatter, it must be escaped later.
- $formatter = \Drupal::service('date.formatter');
- $this->assertIdentical($formatter->format($timestamp, 'custom', '\<\s\c\r\i\p\t\>\a\l\e\r\t\(\'Y\'\)\;\<\/\s\c\r\i\p\t\>'), "", 'Script tags not removed from dates.');
- $this->assertIdentical($formatter->format($timestamp, 'custom', '\<\e\m\>Y\<\/\e\m\>'), '2007', 'Em tags are not removed from dates.');
- }
-
}
diff --git a/core/tests/Drupal/KernelTests/Core/Datetime/FormatDateTest.php b/core/tests/Drupal/KernelTests/Core/Datetime/FormatDateTest.php
new file mode 100644
index 0000000..893b11e
--- /dev/null
+++ b/core/tests/Drupal/KernelTests/Core/Datetime/FormatDateTest.php
@@ -0,0 +1,90 @@
+installConfig(['system']);
+
+ $this->setSetting('locale_custom_strings_' . self::LANGCODE, [
+ '' => array('Sunday' => 'domingo'),
+ 'Long month name' => array('March' => 'marzo'),
+ ]);
+
+ $formats = $this->container->get('entity.manager')
+ ->getStorage('date_format')
+ ->loadMultiple(['long', 'medium', 'short']);
+ $formats['long']->setPattern('l, j. F Y - G:i')->save();
+ $formats['medium']->setPattern('j. F Y - G:i')->save();
+ $formats['short']->setPattern('Y M j - g:ia')->save();
+
+ ConfigurableLanguage::createFromLangcode(static::LANGCODE)->save();
+ }
+
+ /**
+ * Tests the format_date() function.
+ */
+ function testFormatDate() {
+ $timestamp = strtotime('2007-03-26T00:00:00+00:00');
+ $this->assertSame(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T', 'America/Los_Angeles', 'en'), 'Sunday, 25-Mar-07 17:00:00 PDT', 'Test all parameters.');
+ $this->assertSame(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T', 'America/Los_Angeles', self::LANGCODE), 'domingo, 25-Mar-07 17:00:00 PDT', 'Test translated format.');
+ $this->assertSame(format_date($timestamp, 'custom', '\\l, d-M-y H:i:s T', 'America/Los_Angeles', self::LANGCODE), 'l, 25-Mar-07 17:00:00 PDT', 'Test an escaped format string.');
+ $this->assertSame(format_date($timestamp, 'custom', '\\\\l, d-M-y H:i:s T', 'America/Los_Angeles', self::LANGCODE), '\\domingo, 25-Mar-07 17:00:00 PDT', 'Test format containing backslash character.');
+ $this->assertSame(format_date($timestamp, 'custom', '\\\\\\l, d-M-y H:i:s T', 'America/Los_Angeles', self::LANGCODE), '\\l, 25-Mar-07 17:00:00 PDT', 'Test format containing backslash followed by escaped format string.');
+ $this->assertSame(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T', 'Europe/London', 'en'), 'Monday, 26-Mar-07 01:00:00 BST', 'Test a different time zone.');
+
+ // Change the default language and timezone.
+ $this->config('system.site')->set('default_langcode', static::LANGCODE)->save();
+ date_default_timezone_set('America/Los_Angeles');
+
+ // Reset the language manager so new negotiations attempts will fall back on
+ // on the new language.
+ $this->container->get('language_manager')->reset();
+
+ $this->assertSame(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T', 'America/Los_Angeles', 'en'), 'Sunday, 25-Mar-07 17:00:00 PDT', 'Test a different language.');
+ $this->assertSame(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T', 'Europe/London'), 'Monday, 26-Mar-07 01:00:00 BST', 'Test a different time zone.');
+ $this->assertSame(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T'), 'domingo, 25-Mar-07 17:00:00 PDT', 'Test custom date format.');
+ $this->assertSame(format_date($timestamp, 'long'), 'domingo, 25. marzo 2007 - 17:00', 'Test long date format.');
+ $this->assertSame(format_date($timestamp, 'medium'), '25. marzo 2007 - 17:00', 'Test medium date format.');
+ $this->assertSame(format_date($timestamp, 'short'), '2007 Mar 25 - 5:00pm', 'Test short date format.');
+ $this->assertSame(format_date($timestamp), '25. marzo 2007 - 17:00', 'Test default date format.');
+ // Test HTML time element formats.
+ $this->assertSame(format_date($timestamp, 'html_datetime'), '2007-03-25T17:00:00-0700', 'Test html_datetime date format.');
+ $this->assertSame(format_date($timestamp, 'html_date'), '2007-03-25', 'Test html_date date format.');
+ $this->assertSame(format_date($timestamp, 'html_time'), '17:00:00', 'Test html_time date format.');
+ $this->assertSame(format_date($timestamp, 'html_yearless_date'), '03-25', 'Test html_yearless_date date format.');
+ $this->assertSame(format_date($timestamp, 'html_week'), '2007-W12', 'Test html_week date format.');
+ $this->assertSame(format_date($timestamp, 'html_month'), '2007-03', 'Test html_month date format.');
+ $this->assertSame(format_date($timestamp, 'html_year'), '2007', 'Test html_year date format.');
+
+ // HTML is not escaped by the date formatter, it must be escaped later.
+ $formatter = $this->container->get('date.formatter');
+ $this->assertSame($formatter->format($timestamp, 'custom', '\<\s\c\r\i\p\t\>\a\l\e\r\t\(\'Y\'\)\;\<\/\s\c\r\i\p\t\>'), "", 'Script tags not removed from dates.');
+ $this->assertSame($formatter->format($timestamp, 'custom', '\<\e\m\>Y\<\/\e\m\>'), '2007', 'Em tags are not removed from dates.');
+ }
+
+}