test auth contracts
This commit is contained in:
parent
3da9c586c3
commit
b3266b38c8
15 changed files with 457 additions and 165 deletions
28
backend/tests/Fakes/FakeTokenGenerator.php
Normal file
28
backend/tests/Fakes/FakeTokenGenerator.php
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Fakes;
|
||||
|
||||
use App\Auth\TokenGenerator;
|
||||
use RuntimeException;
|
||||
|
||||
class FakeTokenGenerator implements TokenGenerator
|
||||
{
|
||||
private int $callCount = 0;
|
||||
|
||||
/**
|
||||
* @param string[] $tokens
|
||||
*/
|
||||
public function __construct(private array $tokens) {}
|
||||
|
||||
public function generate(): string
|
||||
{
|
||||
if ($this->callCount >= count($this->tokens)) {
|
||||
throw new RuntimeException('FakeTokenGenerator exhausted');
|
||||
}
|
||||
|
||||
$token = $this->tokens[$this->callCount];
|
||||
$this->callCount++;
|
||||
|
||||
return $token;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue