tests/TestUserProvider.php (nouveau): - Implementation de UserProviderInterface pour l'environnement test - loadUserByIdentifier(), refreshUser(), supportsClass() - Le service etait reference dans security.yaml when@test mais n'existait pas config/services_test.yaml (nouveau): - Enregistrement de App\Tests\TestUserProvider comme service public pour que le container test puisse le resoudre tests/Controller/LegalControllerTest.php: - Selecteurs CSS mis a jour: .border-red-600 remplace par .border-red-300 et .border-green-600 par .border-green-300 (glassmorphism) tests/Controller/Admin/AdminControllersTest.php: - testSyncIndex(): ajout de PriceAutomaticRepository et StripeWebhookSecretRepository dans les arguments de SyncController::index() (4 arguments au lieu de 2) tests/Controller/MainControllersTest.php: - testForgotPasswordFullFlow(): sendEmail attendu 2 fois au lieu de 1 (step 2 envoie le code, step 3 envoie la confirmation de changement) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
42 lines
1.1 KiB
PHP
42 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Tests;
|
|
|
|
use App\Entity\User;
|
|
use Symfony\Component\Security\Core\Exception\UserNotFoundException;
|
|
use Symfony\Component\Security\Core\User\UserInterface;
|
|
use Symfony\Component\Security\Core\User\UserProviderInterface;
|
|
|
|
/**
|
|
* @implements UserProviderInterface<User>
|
|
*/
|
|
class TestUserProvider implements UserProviderInterface
|
|
{
|
|
/** @var array<string, User> */
|
|
private array $users = [];
|
|
|
|
public function addUser(User $user): void
|
|
{
|
|
$this->users[$user->getUserIdentifier()] = $user;
|
|
}
|
|
|
|
public function refreshUser(UserInterface $user): UserInterface
|
|
{
|
|
return $this->loadUserByIdentifier($user->getUserIdentifier());
|
|
}
|
|
|
|
public function supportsClass(string $class): bool
|
|
{
|
|
return User::class === $class || is_subclass_of($class, User::class);
|
|
}
|
|
|
|
public function loadUserByIdentifier(string $identifier): UserInterface
|
|
{
|
|
if (!isset($this->users[$identifier])) {
|
|
throw new UserNotFoundException(sprintf('User "%s" not found.', $identifier));
|
|
}
|
|
|
|
return $this->users[$identifier];
|
|
}
|
|
}
|