public function DateTest::testformatDiff in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/tests/Drupal/Tests/Core/Datetime/DateTest.php \Drupal\Tests\Core\Datetime\DateTest::testformatDiff()
Tests the formatDiff method.
@dataProvider providerTestFormatDiff
@covers ::formatDiff
File
- core/
tests/ Drupal/ Tests/ Core/ Datetime/ DateTest.php, line 247 - Contains \Drupal\Tests\Core\Datetime\DateTest.
Class
- DateTest
- @coversDefaultClass \Drupal\Core\Datetime\DateFormatter @group Datetime
Namespace
Drupal\Tests\Core\DatetimeCode
public function testformatDiff($expected, $timestamp1, $timestamp2, $options = array()) {
// Mocks a simple formatPlural implementation.
$this->stringTranslation
->expects($this
->any())
->method('formatPlural')
->with($this
->anything(), $this
->anything(), $this
->anything(), array(), array(
'langcode' => isset($options['langcode']) ? $options['langcode'] : NULL,
))
->will($this
->returnCallback(function ($count, $one, $multiple) {
return $count == 1 ? $one : str_replace('@count', $count, $multiple);
}));
// Mocks a simple translate implementation.
$this->stringTranslation
->expects($this
->any())
->method('translate')
->with($this
->anything())
->will($this
->returnCallback(function ($string, $args, $options) {
return $string;
}));
$this
->assertEquals($expected, $this->dateFormatter
->formatDiff($timestamp1, $timestamp2, $options));
}