- Add DISCOVERY_LOG_LEVEL=debug - Add DISCOVERY_SHOW_PROGRESS=true - Temporary changes for debugging InitializerProcessor fixes on production
94 lines
2.0 KiB
PHP
94 lines
2.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Framework\Waf\Feedback;
|
|
|
|
use App\Framework\DateTime\Clock;
|
|
|
|
/**
|
|
* Test implementation of the Clock interface for unit tests
|
|
*/
|
|
final class TestClock implements Clock
|
|
{
|
|
private \DateTimeImmutable $fixedTime;
|
|
|
|
/**
|
|
* @param string $fixedTime Fixed time in format 'Y-m-d H:i:s'
|
|
*/
|
|
public function __construct(string $fixedTime = '2025-08-04 18:39:00')
|
|
{
|
|
$this->fixedTime = new \DateTimeImmutable($fixedTime);
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function now(): \DateTimeImmutable
|
|
{
|
|
return $this->fixedTime;
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function yesterday(): \DateTimeImmutable
|
|
{
|
|
return $this->fixedTime->modify('-1 day');
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function today(): \DateTimeImmutable
|
|
{
|
|
return $this->fixedTime->setTime(0, 0);
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function tomorrow(): \DateTimeImmutable
|
|
{
|
|
return $this->fixedTime->modify('+1 day');
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function time(int $hour = 0, int $minute = 0, int $second = 0): \DateTimeImmutable
|
|
{
|
|
return $this->fixedTime->setTime($hour, $minute, $second);
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public static function fromTimestamp(int $timestamp): \DateTimeImmutable
|
|
{
|
|
return (new \DateTimeImmutable())->setTimestamp($timestamp);
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public static function fromString(string $datetime): \DateTimeImmutable
|
|
{
|
|
return new \DateTimeImmutable($datetime);
|
|
}
|
|
|
|
/**
|
|
* Set the fixed time to a new value
|
|
*
|
|
* @param string $fixedTime Fixed time in format 'Y-m-d H:i:s'
|
|
* @return self
|
|
*/
|
|
public function withFixedTime(string $fixedTime): self
|
|
{
|
|
$clone = clone $this;
|
|
$clone->fixedTime = new \DateTimeImmutable($fixedTime);
|
|
|
|
return $clone;
|
|
}
|
|
}
|