$timestamp =
strtotime('2007-03-26T00:00:00+00:00'
);
$this->
assertSame('Sunday, 25-Mar-07 17:00:00 PDT',
$formatter->
format($timestamp, 'custom', 'l, d-M-y H:i:s T', 'America/Los_Angeles', 'en'
), 'Test all parameters.'
);
$this->
assertSame('domingo, 25-Mar-07 17:00:00 PDT',
$formatter->
format($timestamp, 'custom', 'l, d-M-y H:i:s T', 'America/Los_Angeles', self::LANGCODE
), 'Test translated format.'
);
$this->
assertSame('l, 25-Mar-07 17:00:00 PDT',
$formatter->
format($timestamp, 'custom', '\\l, d-M-y H:i:s T', 'America/Los_Angeles', self::LANGCODE
), 'Test an escaped format string.'
);
$this->
assertSame('\\domingo, 25-Mar-07 17:00:00 PDT',
$formatter->
format($timestamp, 'custom', '\\\\l, d-M-y H:i:s T', 'America/Los_Angeles', self::LANGCODE
), 'Test format containing backslash character.'
);
$this->
assertSame('\\l, 25-Mar-07 17:00:00 PDT',
$formatter->
format($timestamp, 'custom', '\\\\\\l, d-M-y H:i:s T', 'America/Los_Angeles', self::LANGCODE
), 'Test format containing backslash followed by escaped format string.'
);
$this->
assertSame('Monday, 26-Mar-07 01:00:00 BST',
$formatter->
format($timestamp, 'custom', 'l, d-M-y H:i:s T', 'Europe/London', 'en'
), 'Test a different time zone.'
);
$this->
assertSame('Thu, 01/01/1970 - 00:00',
$formatter->
format(0, 'custom', '', 'UTC', 'en'
), 'Test custom format with empty string.'
);
// Make sure we didn't change the configuration override language.
$this->
assertSame('en',
$language_manager->
getConfigOverrideLanguage()->
getId(), 'Configuration override language not disturbed,'
);
// Test bad format string will use the fallback format.
$this->
assertSame($formatter->
format($timestamp, 'fallback'
),
$formatter->
format($timestamp, 'bad_format_string'
), 'Test fallback format.'
);
$this->
assertSame('en',
$language_manager->
getConfigOverrideLanguage()->
getId(), 'Configuration override language not disturbed,'
);
// 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.