add fake clock
This commit is contained in:
parent
de4d577781
commit
78ffb77f9f
1 changed files with 23 additions and 0 deletions
23
tests/Fakes/FakeClock.php
Normal file
23
tests/Fakes/FakeClock.php
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Fakes;
|
||||
|
||||
use App\Auth\Clock;
|
||||
use DateTimeImmutable;
|
||||
|
||||
class FakeClock implements Clock
|
||||
{
|
||||
public function __construct(
|
||||
private DateTimeImmutable $currentTime,
|
||||
) {}
|
||||
|
||||
public function now(): DateTimeImmutable
|
||||
{
|
||||
return $this->currentTime;
|
||||
}
|
||||
|
||||
public function setTime(DateTimeImmutable $newTime): void
|
||||
{
|
||||
$this->currentTime = $newTime;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue