Commit 794cf89a authored by alexpott's avatar alexpott

Issue #2497585 by mpdonadio, cilefen, borisson_, pjonckiere: Simpletest should...

Issue #2497585 by mpdonadio, cilefen, borisson_, pjonckiere: Simpletest should set a system timezone in setUp
parent 57fb699b
......@@ -485,7 +485,7 @@ public function testDateFormatTranslation() {
// Formatting the date 8 / 27 / 1985 @ 13:37 EST with pattern D should
// display "Tue".
$formatted_date = format_date(494015820, $id, NULL, NULL, 'fr');
$formatted_date = format_date(494015820, $id, NULL, 'America/New_York', 'fr');
$this->assertEqual($formatted_date, 'Tue', 'Got the right formatted date using the date format translation pattern.');
}
}
......
......@@ -117,7 +117,7 @@ public function testConfigTranslation() {
// Formatting the date 8 / 27 / 1985 @ 13:37 EST with pattern D should
// display "Tue".
$formatted_date = format_date(494015820, $type = 'medium', NULL, NULL, $this->langcode);
$formatted_date = format_date(494015820, $type = 'medium', NULL, 'America/New_York', $this->langcode);
$this->assertEqual($formatted_date, 'Tue', 'Got the right formatted date using the date format translation pattern.');
// Assert strings from image module config are not available.
......
......@@ -34,7 +34,7 @@ public static function rawValue($data) {
* Returns the ISO 8601 timestamp.
*/
public static function dateIso8601Value($data) {
return date_iso8601($data['value']);
return \Drupal::service('date.formatter')->format($data['value'], 'custom', 'c', 'UTC');
}
}
......@@ -264,14 +264,14 @@ function _testBasicCommentRdfaMarkup($graph, CommentInterface $comment, $account
// Comment date.
$expected_value = array(
'type' => 'literal',
'value' => date('c', $comment->getCreatedTime()),
'value' => format_date($comment->getCreatedTime(), 'custom', 'c', 'UTC'),
'datatype' => 'http://www.w3.org/2001/XMLSchema#dateTime',
);
$this->assertTrue($graph->hasProperty($comment_uri, 'http://purl.org/dc/terms/date', $expected_value), 'Comment date found in RDF output (dc:date).');
// Comment date.
$expected_value = array(
'type' => 'literal',
'value' => date('c', $comment->getCreatedTime()),
'value' => format_date($comment->getCreatedTime(), 'custom', 'c', 'UTC'),
'datatype' => 'http://www.w3.org/2001/XMLSchema#dateTime',
);
$this->assertTrue($graph->hasProperty($comment_uri, 'http://purl.org/dc/terms/created', $expected_value), 'Comment date found in RDF output (dc:created).');
......
......@@ -356,7 +356,7 @@ protected function assertRdfaCommonNodeProperties($graph, NodeInterface $node, $
// Created date.
$expected_value = array(
'type' => 'literal',
'value' => date_iso8601($node->get('created')->value),
'value' => format_date($node->get('created')->value, 'custom', 'c', 'UTC'),
'lang' => 'en',
);
$this->assertTrue($graph->hasProperty($uri, 'http://schema.org/dateCreated', $expected_value), "$message_prefix created date was found (schema:dateCreated) in teaser.");
......@@ -445,7 +445,7 @@ protected function assertRdfaNodeCommentProperties($graph) {
// Comment created date.
$expected_value = array(
'type' => 'literal',
'value' => date_iso8601($this->articleComment->get('created')->value),
'value' => format_date($this->articleComment->get('created')->value, 'custom', 'c', 'UTC'),
'lang' => 'en',
);
$this->assertTrue($graph->hasProperty($this->articleCommentUri, 'http://schema.org/dateCreated', $expected_value), 'Article comment created date was found (schema:dateCreated).');
......
......@@ -831,6 +831,15 @@ protected function initConfig(ContainerInterface $container) {
->set('css.preprocess', FALSE)
->set('js.preprocess', FALSE)
->save();
// Set an explicit time zone to not rely on the system one, which may vary
// from setup to setup. The Australia/Sydney time zone is chosen so all
// tests are run using an edge case scenario (UTC+10 and DST). This choice
// is made to prevent time zone related regressions and reduce the
// fragility of the testing system in general.
$config->getEditable('system.date')
->set('timezone.default', 'Australia/Sydney')
->save();
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment