function TimeTest::testGetRequestTimeNoRequest

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

@covers ::getRequestTime

File

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

Class

TimeTest
Tests the Time class.

Namespace

Drupal\Tests\Component\Datetime

Code

public function testGetRequestTimeNoRequest() : void {
    // With no request, and no global variable, we expect to get the int part
    // of the microtime.
    $expected = 1234567;
    unset($_SERVER['REQUEST_TIME']);
    $this->assertEquals($expected, $this->time
        ->getRequestTime());
    $_SERVER['REQUEST_TIME'] = 23456789;
    $this->assertEquals(23456789, $this->time
        ->getRequestTime());
}

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