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. 11.x 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 87

Class

TimeTest
@coversDefaultClass \Drupal\Component\Datetime\Time[[api-linebreak]] @group Datetime

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.