Working state but no uploads

This commit is contained in:
julien
2026-03-16 02:33:18 +01:00
parent cc3fbdc830
commit 55d2da9f2f
52 changed files with 121 additions and 49 deletions

View File

@@ -20,6 +20,7 @@ use PHPUnit\Framework\TestCase;
* Vérifie la génération de token, la validation et la réinitialisation
* du mot de passe. Les dépendances sont mockées via leurs interfaces.
*/
#[\PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations]
final class PasswordResetServiceTest extends TestCase
{
/** @var PasswordResetRepositoryInterface&MockObject */
@@ -95,7 +96,7 @@ final class PasswordResetServiceTest extends TestCase
$this->resetRepository->method('invalidateByUserId');
$this->resetRepository->expects($this->once())
->method('create')
->with($user->getId(), $this->isType('string'), $this->isType('string'));
->with($user->getId(), $this->callback('is_string'), $this->callback('is_string'));
$this->mailService->method('send');
$this->service->requestReset('alice@example.com', 'https://blog.exemple.com');
@@ -116,9 +117,9 @@ final class PasswordResetServiceTest extends TestCase
->method('send')
->with(
'alice@example.com',
$this->isType('string'),
$this->callback('is_string'),
'emails/password-reset.twig',
$this->isType('array'),
$this->callback('is_array'),
);
$this->service->requestReset('alice@example.com', 'https://blog.exemple.com');
@@ -173,7 +174,7 @@ final class PasswordResetServiceTest extends TestCase
$tokenRaw = 'montokenbrut';
$tokenHash = hash('sha256', $tokenRaw);
$this->resetRepository->method('findActiveByHash')->with($tokenHash)->willReturn([
$this->resetRepository->expects($this->once())->method('findActiveByHash')->with($tokenHash)->willReturn([
'user_id' => 1,
'token_hash' => $tokenHash,
'expires_at' => date('Y-m-d H:i:s', time() - 3600),
@@ -194,13 +195,13 @@ final class PasswordResetServiceTest extends TestCase
$tokenRaw = 'montokenbrut';
$tokenHash = hash('sha256', $tokenRaw);
$this->resetRepository->method('findActiveByHash')->with($tokenHash)->willReturn([
$this->resetRepository->expects($this->once())->method('findActiveByHash')->with($tokenHash)->willReturn([
'user_id' => $user->getId(),
'token_hash' => $tokenHash,
'expires_at' => date('Y-m-d H:i:s', time() + 3600),
'used_at' => null,
]);
$this->userRepository->method('findById')->with($user->getId())->willReturn($user);
$this->userRepository->expects($this->once())->method('findById')->with($user->getId())->willReturn($user);
$result = $this->service->validateToken($tokenRaw);
@@ -224,8 +225,8 @@ final class PasswordResetServiceTest extends TestCase
'used_at' => null,
];
$this->resetRepository->method('findActiveByHash')->willReturn($row);
$this->userRepository->method('findById')->with(999)->willReturn(null);
$this->resetRepository->expects($this->once())->method('findActiveByHash')->willReturn($row);
$this->userRepository->expects($this->once())->method('findById')->with(999)->willReturn(null);
$result = $this->service->validateToken('token-valide-mais-user-supprime');
@@ -282,7 +283,7 @@ final class PasswordResetServiceTest extends TestCase
$this->resetRepository->expects($this->once())
->method('consumeActiveToken')
->with($tokenHash, $this->isType('string'))
->with($tokenHash, $this->callback('is_string'))
->willReturn([
'user_id' => $user->getId(),
'token_hash' => $tokenHash,