You are here

public function TimeTest::testGetRequestMicroTime in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Component/Datetime/TimeTest.php \Drupal\Tests\Component\Datetime\TimeTest::testGetRequestMicroTime()
  2. 9 core/tests/Drupal/Tests/Component/Datetime/TimeTest.php \Drupal\Tests\Component\Datetime\TimeTest::testGetRequestMicroTime()

Tests the getRequestMicroTime method.

@covers ::getRequestMicroTime

File

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

Class

TimeTest
@coversDefaultClass \Drupal\Component\Datetime\Time @group Datetime

Namespace

Drupal\Tests\Component\Datetime

Code

public function testGetRequestMicroTime() {
  $expected = 1234567.89;
  $request = Request::createFromGlobals();
  $request->server
    ->set('REQUEST_TIME_FLOAT', $expected);

  // Mocks a the request stack getting the current request.
  $this->requestStack
    ->expects($this
    ->any())
    ->method('getCurrentRequest')
    ->willReturn($request);
  $this
    ->assertEquals($expected, $this->time
    ->getRequestMicroTime());
}