You are here

public static function TestTime::setFakeTimeByOffset in Automatic Updates 8.2

Sets a fake time from an offset that will be used in the test.

Parameters

string $offset: A date/time offset string as used by \DateTime::modify.

1 call to TestTime::setFakeTimeByOffset()
ReadinessValidationTest::delayRequestTime in tests/src/Functional/ReadinessValidationTest.php
Delays the request for the test.

File

tests/modules/automatic_updates_test/src/Datetime/TestTime.php, line 49

Class

TestTime
Test service for altering the request time.

Namespace

Drupal\automatic_updates_test\Datetime

Code

public static function setFakeTimeByOffset(string $offset) : void {
  $fake_time = (new \DateTime())
    ->modify($offset)
    ->format('U');
  \Drupal::state()
    ->set('automatic_updates_test.fake_date_time', $fake_time);
}