public function DateTest::testFormatTimeDiffUntil 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::testFormatTimeDiffUntil()
Tests the formatTimeDiffUntil method.
@covers ::formatTimeDiffUntil
File
- core/
tests/ Drupal/ Tests/ Core/ Datetime/ DateTest.php, line 189 - Contains \Drupal\Tests\Core\Datetime\DateTest.
Class
- DateTest
- @coversDefaultClass \Drupal\Core\Datetime\DateFormatter @group Datetime
Namespace
Drupal\Tests\Core\DatetimeCode
public function testFormatTimeDiffUntil() {
$expected = '1 second';
$request_time = $this
->createTimestamp('2013-12-11 10:09:08');
$timestamp = $this
->createTimestamp('2013-12-11 10:09:09');
$options = array();
// Mocks the formatDiff function of the dateformatter object.
$this->dateFormatterStub
->expects($this
->any())
->method('formatDiff')
->with($timestamp, $request_time, $options)
->will($this
->returnValue($expected));
$request = Request::createFromGlobals();
$request->server
->set('REQUEST_TIME', $request_time);
// Mocks a the request stack getting the current request.
$this->requestStack
->expects($this
->any())
->method('getCurrentRequest')
->willReturn($request);
$this
->assertEquals($expected, $this->dateFormatterStub
->formatTimeDiffSince($timestamp, $options));
}