You are here

class TestTimeService in Search API 8

Provides a dummy time service that can be used for testing.

Hierarchy

Expanded class hierarchy of TestTimeService

File

tests/src/Kernel/TestTimeService.php, line 10

Namespace

Drupal\Tests\search_api\Kernel
View source
class TestTimeService extends Time {

  /**
   * The request time to return.
   *
   * @var int
   *
   * @see \Drupal\Tests\search_api\Kernel\TestTimeService::getRequestTime()
   */
  protected $requestTime;

  /**
   * Constructs a TestTimeService object.
   */
  public function __construct() {
    $this->requestTime = time();
  }

  /**
   * {@inheritdoc}
   */
  public function getRequestTime() {
    return $this->requestTime;
  }

  /**
   * Advances the reported request time.
   *
   * @param int $seconds
   *   (optional) Number of seconds by which to advance the reported request
   *   time.
   *
   * @return $this
   */
  public function advanceTime($seconds = 1) {
    $this->requestTime += $seconds;
    return $this;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
TestTimeService::$requestTime protected property The request time to return.
TestTimeService::advanceTime public function Advances the reported request time.
TestTimeService::getRequestTime public function Returns the timestamp for the current request. Overrides Time::getRequestTime
TestTimeService::__construct public function Constructs a TestTimeService object. Overrides Time::__construct
Time::$requestStack protected property The request stack.
Time::getCurrentMicroTime public function Returns the current system time with microsecond precision. Overrides TimeInterface::getCurrentMicroTime
Time::getCurrentTime public function Returns the current system time as an integer. Overrides TimeInterface::getCurrentTime
Time::getRequestMicroTime public function Returns the timestamp for the current request with microsecond precision. Overrides TimeInterface::getRequestMicroTime