Files
football2801 4002ff9fbf
CI / test (push) Has been cancelled
chore: stage all in-progress work before repo split
Web app: new entities (Image, RenderedAsset, SharedImage, Token,
DeviceImageHistory), enums, repositories, controllers, message handlers,
migrations, tests, frontend upload/library/sticker UI, Vue components.

Firmware: EPD background screen binaries + gen scripts, setup_bg header.

Infra: ddev config, test bundle, gitignore coverage dir.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-06 12:11:31 -04:00

50 lines
1.7 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Tests\Unit\Repository;
use App\Entity\User;
use App\Repository\UserRepository;
use App\Tests\AppKernelTestCase;
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
class UserRepositoryTest extends AppKernelTestCase
{
private UserRepository $repo;
protected function setUp(): void
{
parent::setUp();
$this->repo = static::getContainer()->get(UserRepository::class);
}
// UR-01: valid User → password updated in DB
public function test_upgrade_password_updates_password_for_valid_user(): void
{
$user = $this->createUser('ur01@example.com', 'oldpassword');
$userId = $user->getId();
$this->repo->upgradePassword($user, 'newhashed_password');
$this->em()->clear();
$reloaded = $this->em()->find(User::class, $userId);
$this->assertSame('newhashed_password', $reloaded->getPassword());
}
// UR-02: non-User PasswordAuthenticatedUserInterface → throws UnsupportedUserException
public function test_upgrade_password_throws_for_non_user(): void
{
$fakeUser = new class implements PasswordAuthenticatedUserInterface {
public function getPassword(): ?string { return null; }
public function getUserIdentifier(): string { return 'fake'; }
public function getRoles(): array { return []; }
public function eraseCredentials(): void {}
};
$this->expectException(UnsupportedUserException::class);
$this->repo->upgradePassword($fakeUser, 'newpassword');
}
}