add fake token generator
This commit is contained in:
parent
07040851ec
commit
057df09dda
1 changed files with 25 additions and 0 deletions
25
tests/Fakes/FakeTokenGenerator.php
Normal file
25
tests/Fakes/FakeTokenGenerator.php
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Fakes;
|
||||||
|
|
||||||
|
use App\Auth\TokenGenerator;
|
||||||
|
|
||||||
|
class FakeTokenGenerator implements TokenGenerator
|
||||||
|
{
|
||||||
|
private int $callCount = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string[] $predefinedTokens
|
||||||
|
*/
|
||||||
|
public function __construct(
|
||||||
|
private array $predefinedTokens = ['fake-token-0'],
|
||||||
|
) {}
|
||||||
|
|
||||||
|
public function generate(): string
|
||||||
|
{
|
||||||
|
$index = $this->callCount % count($this->predefinedTokens);
|
||||||
|
$this->callCount++;
|
||||||
|
|
||||||
|
return $this->predefinedTokens[$index];
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue