diff --git a/core/lib/Drupal/Core/Datetime/DateFormatter.php b/core/lib/Drupal/Core/Datetime/DateFormatter.php index d784743cd54..e7ded8c538a 100644 --- a/core/lib/Drupal/Core/Datetime/DateFormatter.php +++ b/core/lib/Drupal/Core/Datetime/DateFormatter.php @@ -146,6 +146,9 @@ public function format($timestamp, $type = 'medium', $format = '', $timezone = N * {@inheritdoc} */ public function formatInterval($interval, $granularity = 2, $langcode = NULL) { + if (!is_int($interval)) { + throw new \RuntimeException('$interval is not a string. It is a: ' . gettype($interval)); + } $output = ''; foreach ($this->units as $key => $value) { $key = explode('|', $key); diff --git a/core/scripts/run-tests.sh b/core/scripts/run-tests.sh index 40ed2b3f2f4..2163902ba14 100755 --- a/core/scripts/run-tests.sh +++ b/core/scripts/run-tests.sh @@ -1311,7 +1311,7 @@ function simpletest_script_reporter_write_xml_results() { function simpletest_script_reporter_timer_stop() { echo "\n"; $end = Timer::stop('run-tests'); - echo "Test run duration: " . \Drupal::service('date.formatter')->formatInterval($end['time'] / 1000); + echo "Test run duration: " . \Drupal::service('date.formatter')->formatInterval((int) ($end['time'] / 1000)); echo "\n\n"; }