function TimeTest::testGetRequestTime

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Component/Datetime/TimeTest.php \Drupal\Tests\Component\Datetime\TimeTest::testGetRequestTime()
  2. 8.9.x core/tests/Drupal/Tests/Component/Datetime/TimeTest.php \Drupal\Tests\Component\Datetime\TimeTest::testGetRequestTime()
  3. 10 core/tests/Drupal/Tests/Component/Datetime/TimeTest.php \Drupal\Tests\Component\Datetime\TimeTest::testGetRequestTime()

Tests the getRequestTime method.

@covers ::getRequestTime

File

core/tests/Drupal/Tests/Component/Datetime/TimeTest.php, line 52

Class

TimeTest
Tests the Time class.

Namespace

Drupal\Tests\Component\Datetime

Code

public function testGetRequestTime() : void {
    $expected = 12345678;
    $request = Request::createFromGlobals();
    $request->server
        ->set('REQUEST_TIME', $expected);
    // Mocks a the request stack getting the current request.
    $this->requestStack
        ->expects($this->any())
        ->method('getCurrentRequest')
        ->willReturn($request);
    $this->assertEquals($expected, $this->time
        ->getRequestTime());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.