mirror of
https://github.com/MarijnDoeve/TijdVoorDeTest.git
synced 2026-03-06 12:44:20 +01:00
* Some tests * More tests! * Tests 3 * Move getScores from Candidate to Quiz * Add some suggestions for future refactoring * - **Add Gedmo doctrine-extensions and Stof bundle integration** - Added `stof/doctrine-extensions-bundle` and `gedmo/doctrine-extensions` dependencies. - Integrated `Timestampable` behavior for `Created` fields in entities. - Updated `bundles.php` to register StofDoctrineExtensionsBundle. - Added configuration for the Stof bundle. - Simplified `SeasonVoter` with `match` expression and added new tests. - Minor fixes and adjustments across various files. * WIP * All the tests * Base64 tests * Symfomny 7.4.0 * Update * Update recipe * PHP 8.5 * Rector changes * More 8.5 * Things
46 lines
1.4 KiB
PHP
46 lines
1.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tvdt\Tests\Repository;
|
|
|
|
use PHPUnit\Framework\Attributes\CoversClass;
|
|
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
|
|
use Tvdt\DataFixtures\TestFixtures;
|
|
use Tvdt\Repository\UserRepository;
|
|
|
|
use function PHPUnit\Framework\assertEmpty;
|
|
|
|
#[CoversClass(UserRepository::class)]
|
|
final class UserRepositoryTest extends DatabaseTestCase
|
|
{
|
|
public function testUpgradePassword(): void
|
|
{
|
|
$passwordHasher = self::getContainer()->get(UserPasswordHasherInterface::class);
|
|
$user = $this->getUserByEmail('user1@example.org');
|
|
|
|
$newHash = $passwordHasher->hashPassword($user, TestFixtures::PASSWORD);
|
|
|
|
$this->assertNotSame($newHash, $user->password);
|
|
$this->userRepository->upgradePassword($user, $newHash);
|
|
|
|
$this->entityManager->refresh($user);
|
|
$this->assertSame($newHash, $user->password);
|
|
}
|
|
|
|
public function testMakeAdmin(): void
|
|
{
|
|
$user = $this->getUserByEmail('test@example.org');
|
|
assertEmpty($user->roles);
|
|
$this->userRepository->makeAdmin('test@example.org');
|
|
$this->entityManager->refresh($user);
|
|
$this->assertSame(['ROLE_ADMIN'], $user->roles);
|
|
}
|
|
|
|
public function testMakeAdminInvalidEmail(): void
|
|
{
|
|
$this->expectException(\InvalidArgumentException::class);
|
|
$this->userRepository->makeAdmin('invalid@example.org');
|
|
}
|
|
}
|