TestTime.php

Same filename in other branches
  1. 8.9.x core/modules/update/tests/modules/update_test/src/Datetime/TestTime.php
  2. 10 core/modules/update/tests/modules/update_test/src/Datetime/TestTime.php
  3. 11.x core/modules/update/tests/modules/update_test/src/Datetime/TestTime.php

Namespace

Drupal\update_test\Datetime

File

core/modules/update/tests/modules/update_test/src/Datetime/TestTime.php

View source
<?php

namespace Drupal\update_test\Datetime;

use Drupal\Component\Datetime\Time;

/**
 * Test service for altering the request time.
 */
class TestTime extends Time {
    
    /**
     * {@inheritdoc}
     */
    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();
    }

}

Classes

Title Deprecated Summary
TestTime Test service for altering the request time.

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