function TestTime::getRequestTime

Same name in other branches
  1. 9 core/modules/update/tests/modules/update_test/src/Datetime/TestTime.php \Drupal\update_test\Datetime\TestTime::getRequestTime()
  2. 8.9.x core/modules/update/tests/modules/update_test/src/Datetime/TestTime.php \Drupal\update_test\Datetime\TestTime::getRequestTime()
  3. 11.x core/modules/update/tests/modules/update_test/src/Datetime/TestTime.php \Drupal\update_test\Datetime\TestTime::getRequestTime()
  4. 11.x core/modules/package_manager/tests/src/Kernel/StageBaseTest.php \Drupal\Tests\package_manager\Kernel\TestTime::getRequestTime()

Overrides Time::getRequestTime

File

core/modules/update/tests/modules/update_test/src/Datetime/TestTime.php, line 15

Class

TestTime
Test service for altering the request time.

Namespace

Drupal\update_test\Datetime

Code

public function getRequestTime() {
    if ($mock_date = \Drupal::state()->get('update_test.mock_date', NULL)) {
        return \DateTime::createFromFormat('Y-m-d', $mock_date)->getTimestamp();
    }
    return parent::getRequestTime();
}

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