3 Commits

Author SHA1 Message Date
dependabot[bot]
dd1a5295a7 Bump symfony/mailer from 7.4.0 to 8.0.0
Bumps [symfony/mailer](https://github.com/symfony/mailer) from 7.4.0 to 8.0.0.
- [Release notes](https://github.com/symfony/mailer/releases)
- [Changelog](https://github.com/symfony/mailer/blob/7.3/CHANGELOG.md)
- [Commits](https://github.com/symfony/mailer/compare/v7.4.0...v8.0.0)

---
updated-dependencies:
- dependency-name: symfony/mailer
  dependency-version: 8.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-12-11 15:49:20 +00:00
b57faaf431 Update to 7.4.2 (#68)
Some checks failed
CI / Tests (push) Failing after 39s
CI / Build and deploy to ${{ startsWith(github.ref, 'refs/tags/') && 'production' || (github.ref == 'refs/heads/main' && 'acceptance' || '') }} (push) Has been skipped
2025-12-11 16:48:16 +01:00
bcd6a157a8 Create Testcoverage and upgrade Symfomy and PHP
Some checks failed
CI / Tests (push) Failing after 1m8s
CI / Build and deploy to ${{ startsWith(github.ref, 'refs/tags/') && 'production' || (github.ref == 'refs/heads/main' && 'acceptance' || '') }} (push) Has been skipped
* 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
2025-11-28 22:56:09 +01:00
22 changed files with 2841 additions and 1109 deletions

View File

@@ -1,4 +1,3 @@
# define your env variables for the test env here # define your env variables for the test env here
KERNEL_CLASS='Tvdt\Kernel' KERNEL_CLASS='Tvdt\Kernel'
APP_SECRET='$ecretf0rt3st' APP_SECRET='$ecretf0rt3st'
SYMFONY_DEPRECATIONS_HELPER=999999

7
.idea/php.xml generated
View File

@@ -50,7 +50,6 @@
<path value="$PROJECT_DIR$/vendor/psr/event-dispatcher" /> <path value="$PROJECT_DIR$/vendor/psr/event-dispatcher" />
<path value="$PROJECT_DIR$/vendor/symfony/cache" /> <path value="$PROJECT_DIR$/vendor/symfony/cache" />
<path value="$PROJECT_DIR$/vendor/symfony/validator" /> <path value="$PROJECT_DIR$/vendor/symfony/validator" />
<path value="$PROJECT_DIR$/vendor/symfony/browser-kit" />
<path value="$PROJECT_DIR$/vendor/symfony/asset" /> <path value="$PROJECT_DIR$/vendor/symfony/asset" />
<path value="$PROJECT_DIR$/vendor/fidry/cpu-core-counter" /> <path value="$PROJECT_DIR$/vendor/fidry/cpu-core-counter" />
<path value="$PROJECT_DIR$/vendor/symfony/ux-turbo" /> <path value="$PROJECT_DIR$/vendor/symfony/ux-turbo" />
@@ -95,7 +94,6 @@
<path value="$PROJECT_DIR$/vendor/symfony/psr-http-message-bridge" /> <path value="$PROJECT_DIR$/vendor/symfony/psr-http-message-bridge" />
<path value="$PROJECT_DIR$/vendor/symfony/stopwatch" /> <path value="$PROJECT_DIR$/vendor/symfony/stopwatch" />
<path value="$PROJECT_DIR$/vendor/masterminds/html5" /> <path value="$PROJECT_DIR$/vendor/masterminds/html5" />
<path value="$PROJECT_DIR$/vendor/symfony/dom-crawler" />
<path value="$PROJECT_DIR$/vendor/symfony/event-dispatcher-contracts" /> <path value="$PROJECT_DIR$/vendor/symfony/event-dispatcher-contracts" />
<path value="$PROJECT_DIR$/vendor/symfony/twig-bundle" /> <path value="$PROJECT_DIR$/vendor/symfony/twig-bundle" />
<path value="$PROJECT_DIR$/vendor/symfony/property-access" /> <path value="$PROJECT_DIR$/vendor/symfony/property-access" />
@@ -198,6 +196,9 @@
<path value="$PROJECT_DIR$/vendor/doctrine/migrations" /> <path value="$PROJECT_DIR$/vendor/doctrine/migrations" />
<path value="$PROJECT_DIR$/vendor/evenement/evenement" /> <path value="$PROJECT_DIR$/vendor/evenement/evenement" />
<path value="$PROJECT_DIR$/vendor/stof/doctrine-extensions-bundle" /> <path value="$PROJECT_DIR$/vendor/stof/doctrine-extensions-bundle" />
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-php84" />
<path value="$PROJECT_DIR$/vendor/symfony/dom-crawler" />
<path value="$PROJECT_DIR$/vendor/symfony/browser-kit" />
</include_path> </include_path>
</component> </component>
<component name="PhpInterpreters"> <component name="PhpInterpreters">
@@ -276,7 +277,7 @@
</interpreter> </interpreter>
</phpInfoCache> </phpInfoCache>
</component> </component>
<component name="PhpProjectSharedConfiguration" php_language_level="8.4" /> <component name="PhpProjectSharedConfiguration" php_language_level="8.5" />
<component name="PhpStan"> <component name="PhpStan">
<PhpStan_settings> <PhpStan_settings>
<phpstan_by_interpreter interpreter_id="96512cb2-7b9e-4e1d-bfa2-bf7f3be424c8" tool_path="vendor/bin/phpstan" timeout="60000" /> <phpstan_by_interpreter interpreter_id="96512cb2-7b9e-4e1d-bfa2-bf7f3be424c8" tool_path="vendor/bin/phpstan" timeout="60000" />

View File

@@ -9,6 +9,7 @@ $finder = new Finder()
->in(__DIR__) ->in(__DIR__)
->exclude('var') ->exclude('var')
->exclude('bin') ->exclude('bin')
->notPath(['config/reference.php'])
; ;
return new Config() return new Config()
@@ -35,4 +36,5 @@ return new Config()
]) ])
->setRiskyAllowed(true) ->setRiskyAllowed(true)
->setFinder($finder) ->setFinder($finder)
->setUnsupportedPhpVersionAllowed(true)
; ;

View File

@@ -1,7 +1,7 @@
#syntax=docker/dockerfile:1 #syntax=docker/dockerfile:1
# Versions # Versions
FROM dunglas/frankenphp:1-php8.4 AS frankenphp_upstream FROM dunglas/frankenphp:1-php8.5 AS frankenphp_upstream
# The different stages of this Dockerfile are meant to be built into separate images # The different stages of this Dockerfile are meant to be built into separate images
# https://docs.docker.com/develop/develop-images/multistage-build/#stop-at-a-specific-build-stage # https://docs.docker.com/develop/develop-images/multistage-build/#stop-at-a-specific-build-stage
@@ -72,7 +72,7 @@ RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"
RUN set -eux; \ RUN set -eux; \
install-php-extensions \ install-php-extensions \
xdebug \ xdebug/xdebug@3.5.0alpha3 \
; ;
COPY --link frankenphp/conf.d/20-app.dev.ini $PHP_INI_DIR/app.conf.d/ COPY --link frankenphp/conf.d/20-app.dev.ini $PHP_INI_DIR/app.conf.d/

View File

@@ -6,68 +6,68 @@
"minimum-stability": "stable", "minimum-stability": "stable",
"prefer-stable": true, "prefer-stable": true,
"require": { "require": {
"php": ">=8.4", "php": ">=8.5",
"ext-ctype": "*", "ext-ctype": "*",
"ext-iconv": "*", "ext-iconv": "*",
"doctrine/dbal": "^4.3.4", "doctrine/dbal": "^4.3.4",
"doctrine/doctrine-bundle": "^3.0", "doctrine/doctrine-bundle": "^3.0",
"doctrine/doctrine-migrations-bundle": "^3.5.0", "doctrine/doctrine-migrations-bundle": "^3.7.0",
"doctrine/orm": "^3.5.2", "doctrine/orm": "^3.5.7",
"martin-georgiev/postgresql-for-doctrine": "^3.5.1", "martin-georgiev/postgresql-for-doctrine": "^3.6.2",
"phpdocumentor/reflection-docblock": "^5.6.3", "phpdocumentor/reflection-docblock": "^5.6.4",
"phpoffice/phpspreadsheet": "^5.1", "phpoffice/phpspreadsheet": "^5.3",
"phpstan/phpdoc-parser": "^2.3", "phpstan/phpdoc-parser": "^2.3",
"runtime/frankenphp-symfony": "^0.2.0", "runtime/frankenphp-symfony": "^0.2.0",
"sentry/sentry-symfony": "^5.6", "sentry/sentry-symfony": "^5.6",
"stof/doctrine-extensions-bundle": "^1.14", "stof/doctrine-extensions-bundle": "^1.14",
"symfony/asset": "7.3.*", "symfony/asset": "7.4.*",
"symfony/asset-mapper": "7.3.*", "symfony/asset-mapper": "7.4.*",
"symfony/brevo-mailer": "7.3.*", "symfony/brevo-mailer": "7.4.*",
"symfony/console": "7.3.*", "symfony/console": "7.4.*",
"symfony/dotenv": "7.3.*", "symfony/dotenv": "7.4.*",
"symfony/flex": "^2.8.2", "symfony/flex": "^2.10.0",
"symfony/form": "7.3.*", "symfony/form": "7.4.*",
"symfony/framework-bundle": "7.3.*", "symfony/framework-bundle": "7.4.*",
"symfony/mailer": "7.3.*", "symfony/mailer": "8.0.*",
"symfony/property-access": "7.3.*", "symfony/property-access": "7.4.*",
"symfony/property-info": "7.3.*", "symfony/property-info": "7.4.*",
"symfony/runtime": "7.3.*", "symfony/runtime": "7.4.*",
"symfony/security-bundle": "7.3.*", "symfony/security-bundle": "7.4.*",
"symfony/security-csrf": "7.3.*", "symfony/security-csrf": "7.4.*",
"symfony/serializer": "7.3.*", "symfony/serializer": "7.4.*",
"symfony/translation": "7.3.*", "symfony/translation": "7.4.*",
"symfony/twig-bundle": "7.3.*", "symfony/twig-bundle": "7.4.*",
"symfony/uid": "7.3.*", "symfony/uid": "7.4.*",
"symfony/ux-turbo": "^2.30.0", "symfony/ux-turbo": "^2.31.0",
"symfony/validator": "7.3.*", "symfony/validator": "7.4.*",
"symfony/yaml": "7.3.*", "symfony/yaml": "7.4.*",
"symfonycasts/sass-bundle": "^0.8.3", "symfonycasts/sass-bundle": "^0.8.3",
"symfonycasts/verify-email-bundle": "^1.17.4", "symfonycasts/verify-email-bundle": "^1.17.4",
"thecodingmachine/safe": "^3.3.0", "thecodingmachine/safe": "^3.3.0",
"twig/extra-bundle": "^3.21", "twig/extra-bundle": "^3.22.1",
"twig/intl-extra": "^3.21", "twig/intl-extra": "^3.22.1",
"twig/twig": "^3.21.1" "twig/twig": "^3.22.0"
}, },
"require-dev": { "require-dev": {
"dama/doctrine-test-bundle": "^8.4", "dama/doctrine-test-bundle": "^8.4",
"doctrine/doctrine-fixtures-bundle": "^4.3", "doctrine/doctrine-fixtures-bundle": "^4.3",
"friendsofphp/php-cs-fixer": "^3.89.0", "friendsofphp/php-cs-fixer": "^3.90.0",
"phpstan/extension-installer": "^1.4.3", "phpstan/extension-installer": "^1.4.3",
"phpstan/phpstan": "^2.1.31", "phpstan/phpstan": "^2.1.32",
"phpstan/phpstan-doctrine": "^2.0.10", "phpstan/phpstan-doctrine": "^2.0.11",
"phpstan/phpstan-phpunit": "^2.0.7", "phpstan/phpstan-phpunit": "^2.0.8",
"phpstan/phpstan-symfony": "^2.0.8", "phpstan/phpstan-symfony": "^2.0.8",
"phpunit/phpunit": "^12.4.1", "phpunit/phpunit": "^12.4.4",
"rector/rector": "^2.2.3", "rector/rector": "^2.2.9",
"roave/security-advisories": "dev-latest", "roave/security-advisories": "dev-latest",
"symfony/browser-kit": "7.3.*", "symfony/browser-kit": "7.4.*",
"symfony/css-selector": "7.3.*", "symfony/css-selector": "7.4.*",
"symfony/maker-bundle": "^1.64.0", "symfony/maker-bundle": "^1.65.1",
"symfony/phpunit-bridge": "7.3.*", "symfony/phpunit-bridge": "7.4.*",
"symfony/stopwatch": "7.3.*", "symfony/stopwatch": "7.4.*",
"symfony/web-profiler-bundle": "7.3.*", "symfony/web-profiler-bundle": "7.4.*",
"thecodingmachine/phpstan-safe-rule": "^1.4.1", "thecodingmachine/phpstan-safe-rule": "^1.4.3",
"vincentlanglet/twig-cs-fixer": "^3.10.0" "vincentlanglet/twig-cs-fixer": "^3.11.0"
}, },
"config": { "config": {
"allow-plugins": { "allow-plugins": {
@@ -100,7 +100,8 @@
"symfony/polyfill-php81": "*", "symfony/polyfill-php81": "*",
"symfony/polyfill-php82": "*", "symfony/polyfill-php82": "*",
"symfony/polyfill-php83": "*", "symfony/polyfill-php83": "*",
"symfony/polyfill-php84": "*" "symfony/polyfill-php84": "*",
"symfony/polyfill-php85": "*"
}, },
"scripts": { "scripts": {
"auto-scripts": { "auto-scripts": {
@@ -121,7 +122,7 @@
"extra": { "extra": {
"symfony": { "symfony": {
"allow-contrib": false, "allow-contrib": false,
"require": "7.3.*", "require": "7.4.*",
"docker": true "docker": true
} }
} }

2031
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,31 +1,36 @@
when@prod: when@prod:
sentry: sentry:
dsn: '%env(SENTRY_DSN)%' dsn: '%env(SENTRY_DSN)%'
# Add request headers, cookies, IP address and the authenticated user
# see https://docs.sentry.io/platforms/php/data-management/data-collected/ for more info
# send_default_pii: true
options: options:
traces_sample_rate: 1.0 # Add request headers, cookies, IP address and the authenticated user
profiles_sample_rate: 1.0 # see https://docs.sentry.io/platforms/php/data-management/data-collected/ for more info
# send_default_pii: true
ignore_exceptions: ignore_exceptions:
- 'Symfony\Component\ErrorHandler\Error\FatalError' - 'Symfony\Component\ErrorHandler\Error\FatalError'
- 'Symfony\Component\Debug\Exception\FatalErrorException' - 'Symfony\Component\Debug\Exception\FatalErrorException'
#
# If you are using Monolog, you also need this additional configuration to log the errors correctly: # # If you are using Monolog, you also need this additional configuration to log the errors correctly:
# https://docs.sentry.io/platforms/php/guides/symfony/#monolog-integration # # https://docs.sentry.io/platforms/php/guides/symfony/#monolog-integration
# register_error_listener: false # register_error_listener: false
# register_error_handler: false # register_error_handler: false
#
# monolog: # monolog:
# handlers: # handlers:
# # Use this only if you don't want to use structured logging and instead receive
# # certain log levels as errors.
# sentry: # sentry:
# type: sentry # type: sentry
# level: !php/const Monolog\Logger::ERROR # level: !php/const Monolog\Logger::ERROR
# hub_id: Sentry\State\HubInterface # hub_id: Sentry\State\HubInterface
# fill_extra_context: true # Enables sending monolog context to Sentry
# Uncomment these lines to register a log message processor that resolves PSR-3 placeholders # process_psr_3_messages: false # Disables the resolution of PSR-3 placeholders
# https://docs.sentry.io/platforms/php/guides/symfony/#monolog-integration #
# # Use this for structured log integration
# sentry_logs:
# type: service
# id: Sentry\SentryBundle\Monolog\LogsHandler
#
# services: # services:
# Monolog\Processor\PsrLogMessageProcessor: # Sentry\SentryBundle\Monolog\LogsHandler:
# tags: { name: monolog.processor, handler: sentry } # arguments:
# - !php/const Monolog\Logger::INFO

1636
config/reference.php Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -13,6 +13,7 @@ return RectorConfig::configure()
__DIR__.'/src', __DIR__.'/src',
__DIR__.'/tests', __DIR__.'/tests',
]) ])
->withSkip([__DIR__.'/config/reference.php'])
->withSymfonyContainerXml(__DIR__.'/var/cache/dev/Tvdt_KernelDevDebugContainer.xml') ->withSymfonyContainerXml(__DIR__.'/var/cache/dev/Tvdt_KernelDevDebugContainer.xml')
->withSymfonyContainerPhp(__DIR__.'/tests/symfony-container.php') ->withSymfonyContainerPhp(__DIR__.'/tests/symfony-container.php')
->registerService(SymfonyRoutesProvider::class, SymfonyRoutesProviderInterface::class) ->registerService(SymfonyRoutesProvider::class, SymfonyRoutesProviderInterface::class)

View File

@@ -26,6 +26,7 @@ final class BackofficeController extends AbstractController
public function __construct( public function __construct(
private readonly SeasonRepository $seasonRepository, private readonly SeasonRepository $seasonRepository,
private readonly Security $security, private readonly Security $security,
private readonly QuizSpreadsheetService $excel,
) {} ) {}
#[Route('/backoffice/', name: 'tvdt_backoffice_index')] #[Route('/backoffice/', name: 'tvdt_backoffice_index')]
@@ -68,9 +69,9 @@ final class BackofficeController extends AbstractController
} }
#[Route('/backoffice/template', name: 'tvdt_backoffice_template', priority: 10)] #[Route('/backoffice/template', name: 'tvdt_backoffice_template', priority: 10)]
public function getTemplate(QuizSpreadsheetService $excel): Response public function getTemplate(): StreamedResponse
{ {
$response = new StreamedResponse($excel->generateTemplate()); $response = new StreamedResponse($this->excel->generateTemplate());
$response->headers->set('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); $response->headers->set('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
$response->headers->set('Content-Disposition', 'attachment; filename="template.xlsx"'); $response->headers->set('Content-Disposition', 'attachment; filename="template.xlsx"');

View File

@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace Tvdt\Controller\Backoffice; namespace Tvdt\Controller\Backoffice;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Routing\Attribute\Route;
@@ -17,14 +18,16 @@ use Tvdt\Factory\EliminationFactory;
final class PrepareEliminationController extends AbstractController final class PrepareEliminationController extends AbstractController
{ {
public function __construct(private readonly EliminationFactory $eliminationFactory) {}
#[Route( #[Route(
'/backoffice/season/{seasonCode:season}/quiz/{quiz}/elimination/prepare', '/backoffice/season/{seasonCode:season}/quiz/{quiz}/elimination/prepare',
name: 'tvdt_prepare_elimination', name: 'tvdt_prepare_elimination',
requirements: ['seasonCode' => self::SEASON_CODE_REGEX, 'quiz' => Requirement::UUID], requirements: ['seasonCode' => self::SEASON_CODE_REGEX, 'quiz' => Requirement::UUID],
)] )]
public function index(Season $season, Quiz $quiz, EliminationFactory $eliminationFactory): Response public function index(Season $season, Quiz $quiz): RedirectResponse
{ {
$elimination = $eliminationFactory->createEliminationFromQuiz($quiz); $elimination = $this->eliminationFactory->createEliminationFromQuiz($quiz);
return $this->redirectToRoute('tvdt_prepare_elimination_view', ['elimination' => $elimination->id]); return $this->redirectToRoute('tvdt_prepare_elimination_view', ['elimination' => $elimination->id]);
} }

View File

@@ -30,6 +30,7 @@ class QuizController extends AbstractController
public function __construct( public function __construct(
private readonly QuizRepository $quizRepository, private readonly QuizRepository $quizRepository,
private readonly TranslatorInterface $translator, private readonly TranslatorInterface $translator,
private readonly QuizCandidateRepository $quizCandidateRepository,
) {} ) {}
#[IsGranted(SeasonVoter::EDIT, subject: 'season')] #[IsGranted(SeasonVoter::EDIT, subject: 'season')]
@@ -71,10 +72,10 @@ class QuizController extends AbstractController
name: 'tvdt_backoffice_quiz_clear', name: 'tvdt_backoffice_quiz_clear',
requirements: ['quiz' => Requirement::UUID], requirements: ['quiz' => Requirement::UUID],
)] )]
public function clearQuiz(Quiz $quiz, QuizRepository $quizRepository): RedirectResponse public function clearQuiz(Quiz $quiz): RedirectResponse
{ {
try { try {
$quizRepository->clearQuiz($quiz); $this->quizRepository->clearQuiz($quiz);
$this->addFlash('success', $this->translator->trans('Quiz cleared')); $this->addFlash('success', $this->translator->trans('Quiz cleared'));
} catch (ErrorClearingQuizException) { } catch (ErrorClearingQuizException) {
$this->addFlash('error', $this->translator->trans('Error clearing quiz')); $this->addFlash('error', $this->translator->trans('Error clearing quiz'));
@@ -89,9 +90,9 @@ class QuizController extends AbstractController
name: 'tvdt_backoffice_quiz_delete', name: 'tvdt_backoffice_quiz_delete',
requirements: ['quiz' => Requirement::UUID], requirements: ['quiz' => Requirement::UUID],
)] )]
public function deleteQuiz(Quiz $quiz, QuizRepository $quizRepository): RedirectResponse public function deleteQuiz(Quiz $quiz): RedirectResponse
{ {
$quizRepository->deleteQuiz($quiz); $this->quizRepository->deleteQuiz($quiz);
$this->addFlash('success', $this->translator->trans('Quiz deleted')); $this->addFlash('success', $this->translator->trans('Quiz deleted'));
@@ -104,7 +105,7 @@ class QuizController extends AbstractController
name: 'tvdt_backoffice_modify_correction', name: 'tvdt_backoffice_modify_correction',
requirements: ['quiz' => Requirement::UUID, 'candidate' => Requirement::UUID], requirements: ['quiz' => Requirement::UUID, 'candidate' => Requirement::UUID],
)] )]
public function modifyCorrection(Quiz $quiz, Candidate $candidate, QuizCandidateRepository $quizCandidateRepository, Request $request): RedirectResponse public function modifyCorrection(Quiz $quiz, Candidate $candidate, Request $request): RedirectResponse
{ {
if (!$request->isMethod('POST')) { if (!$request->isMethod('POST')) {
throw new MethodNotAllowedHttpException(['POST']); throw new MethodNotAllowedHttpException(['POST']);
@@ -112,7 +113,7 @@ class QuizController extends AbstractController
$corrections = (float) $request->request->get('corrections'); $corrections = (float) $request->request->get('corrections');
$quizCandidateRepository->setCorrectionsForCandidate($quiz, $candidate, $corrections); $this->quizCandidateRepository->setCorrectionsForCandidate($quiz, $candidate, $corrections);
return $this->redirectToRoute('tvdt_backoffice_quiz', ['seasonCode' => $quiz->season->seasonCode, 'quiz' => $quiz->id]); return $this->redirectToRoute('tvdt_backoffice_quiz', ['seasonCode' => $quiz->season->seasonCode, 'quiz' => $quiz->id]);
} }

View File

@@ -30,6 +30,7 @@ class SeasonController extends AbstractController
public function __construct( public function __construct(
private readonly TranslatorInterface $translator, private readonly TranslatorInterface $translator,
private readonly EntityManagerInterface $em, private readonly EntityManagerInterface $em,
private readonly QuizSpreadsheetService $quizSpreadsheet,
) {} ) {}
#[IsGranted(SeasonVoter::EDIT, subject: 'season')] #[IsGranted(SeasonVoter::EDIT, subject: 'season')]
@@ -87,7 +88,7 @@ class SeasonController extends AbstractController
requirements: ['seasonCode' => self::SEASON_CODE_REGEX], requirements: ['seasonCode' => self::SEASON_CODE_REGEX],
priority: 10, priority: 10,
)] )]
public function addQuiz(Request $request, Season $season, QuizSpreadsheetService $quizSpreadsheet): Response public function addQuiz(Request $request, Season $season): Response
{ {
$quiz = new Quiz(); $quiz = new Quiz();
$form = $this->createForm(UploadQuizFormType::class, $quiz); $form = $this->createForm(UploadQuizFormType::class, $quiz);
@@ -98,7 +99,7 @@ class SeasonController extends AbstractController
/* @var UploadedFile $sheet */ /* @var UploadedFile $sheet */
$sheet = $form->get('sheet')->getData(); $sheet = $form->get('sheet')->getData();
$quizSpreadsheet->xlsxToQuiz($quiz, $sheet); $this->quizSpreadsheet->xlsxToQuiz($quiz, $sheet);
$quiz->season = $season; $quiz->season = $season;
$this->em->persist($quiz); $this->em->persist($quiz);

View File

@@ -26,7 +26,7 @@ use function Symfony\Component\Translation\t;
#[IsGranted('ROLE_USER')] #[IsGranted('ROLE_USER')]
final class EliminationController extends AbstractController final class EliminationController extends AbstractController
{ {
public function __construct(private readonly TranslatorInterface $translator) {} public function __construct(private readonly TranslatorInterface $translator, private readonly CandidateRepository $candidateRepository) {}
#[IsGranted(SeasonVoter::ELIMINATION, 'elimination')] #[IsGranted(SeasonVoter::ELIMINATION, 'elimination')]
#[Route('/elimination/{elimination}', name: 'tvdt_elimination', requirements: ['elimination' => Requirement::UUID])] #[Route('/elimination/{elimination}', name: 'tvdt_elimination', requirements: ['elimination' => Requirement::UUID])]
@@ -50,9 +50,9 @@ final class EliminationController extends AbstractController
#[IsGranted(SeasonVoter::ELIMINATION, 'elimination')] #[IsGranted(SeasonVoter::ELIMINATION, 'elimination')]
#[Route('/elimination/{elimination}/{candidateHash}', name: 'tvdt_elimination_candidate', requirements: ['elimination' => Requirement::UUID, 'candidateHash' => self::CANDIDATE_HASH_REGEX])] #[Route('/elimination/{elimination}/{candidateHash}', name: 'tvdt_elimination_candidate', requirements: ['elimination' => Requirement::UUID, 'candidateHash' => self::CANDIDATE_HASH_REGEX])]
public function candidateScreen(Elimination $elimination, string $candidateHash, CandidateRepository $candidateRepository): Response public function candidateScreen(Elimination $elimination, string $candidateHash): Response
{ {
$candidate = $candidateRepository->getCandidateByHash($elimination->quiz->season, $candidateHash); $candidate = $this->candidateRepository->getCandidateByHash($elimination->quiz->season, $candidateHash);
if (!$candidate instanceof Candidate) { if (!$candidate instanceof Candidate) {
$this->addFlash(FlashType::Warning, $this->addFlash(FlashType::Warning,
t('Cound not find candidate with name %name%', ['%name%' => Base64::base64UrlDecode($candidateHash)])->trans($this->translator), t('Cound not find candidate with name %name%', ['%name%' => Base64::base64UrlDecode($candidateHash)])->trans($this->translator),

View File

@@ -15,17 +15,17 @@ use Tvdt\Enum\FlashType;
#[AsController] #[AsController]
final class LoginController extends AbstractController final class LoginController extends AbstractController
{ {
public function __construct(private readonly AuthenticationUtils $authenticationUtils, private readonly TranslatorInterface $translator) {}
#[Route(path: '/login', name: 'tvdt_login_login')] #[Route(path: '/login', name: 'tvdt_login_login')]
public function login(AuthenticationUtils $authenticationUtils, TranslatorInterface $translator): Response public function login(): Response
{ {
// get the login error if there is one // get the login error if there is one
$error = $authenticationUtils->getLastAuthenticationError(); $error = $this->authenticationUtils->getLastAuthenticationError();
// last username entered by the user // last username entered by the user
$lastUsername = $authenticationUtils->getLastUsername(); $lastUsername = $this->authenticationUtils->getLastUsername();
if ($error instanceof AuthenticationException) { if ($error instanceof AuthenticationException) {
$this->addFlash(FlashType::Danger, $translator->trans($error->getMessageKey(), $error->getMessageData(), 'security')); $this->addFlash(FlashType::Danger, $this->translator->trans($error->getMessageKey(), $error->getMessageData(), 'security'));
} }
return $this->render('backoffice/login/login.html.twig', [ return $this->render('backoffice/login/login.html.twig', [

View File

@@ -30,10 +30,10 @@ use Tvdt\Repository\SeasonRepository;
#[AsController] #[AsController]
final class QuizController extends AbstractController final class QuizController extends AbstractController
{ {
public function __construct(private readonly TranslatorInterface $translator, private readonly EntityManagerInterface $entityManager) {} public function __construct(private readonly TranslatorInterface $translator, private readonly EntityManagerInterface $entityManager, private readonly SeasonRepository $seasonRepository, private readonly CandidateRepository $candidateRepository, private readonly QuestionRepository $questionRepository, private readonly AnswerRepository $answerRepository, private readonly QuizCandidateRepository $quizCandidateRepository) {}
#[Route(path: '/', name: 'tvdt_quiz_select_season', methods: ['GET', 'POST'])] #[Route(path: '/', name: 'tvdt_quiz_select_season', methods: ['GET', 'POST'])]
public function selectSeason(Request $request, SeasonRepository $seasonRepository): Response public function selectSeason(Request $request): Response
{ {
$form = $this->createForm(SelectSeasonType::class); $form = $this->createForm(SelectSeasonType::class);
$form->handleRequest($request); $form->handleRequest($request);
@@ -41,7 +41,7 @@ final class QuizController extends AbstractController
if ($form->isSubmitted() && $form->isValid()) { if ($form->isSubmitted() && $form->isValid()) {
$seasonCode = $form->get('season_code')->getData(); $seasonCode = $form->get('season_code')->getData();
if ([] === $seasonRepository->findBy(['seasonCode' => $seasonCode])) { if ([] === $this->seasonRepository->findBy(['seasonCode' => $seasonCode])) {
$this->addFlash(FlashType::Warning, $this->translator->trans('Invalid season code')); $this->addFlash(FlashType::Warning, $this->translator->trans('Invalid season code'));
return $this->redirectToRoute('tvdt_quiz_select_season'); return $this->redirectToRoute('tvdt_quiz_select_season');
@@ -80,12 +80,8 @@ final class QuizController extends AbstractController
Season $season, Season $season,
string $nameHash, string $nameHash,
Request $request, Request $request,
CandidateRepository $candidateRepository,
QuestionRepository $questionRepository,
AnswerRepository $answerRepository,
QuizCandidateRepository $quizCandidateRepository,
): Response { ): Response {
$candidate = $candidateRepository->getCandidateByHash($season, $nameHash); $candidate = $this->candidateRepository->getCandidateByHash($season, $nameHash);
if (!$candidate instanceof Candidate) { if (!$candidate instanceof Candidate) {
$this->addFlash(FlashType::Danger, $this->translator->trans('Candidate not found')); $this->addFlash(FlashType::Danger, $this->translator->trans('Candidate not found'));
@@ -103,7 +99,7 @@ final class QuizController extends AbstractController
if ('POST' === $request->getMethod()) { if ('POST' === $request->getMethod()) {
// TODO: Extract saving answer logic to a service // TODO: Extract saving answer logic to a service
$answer = $answerRepository->findOneBy(['id' => $request->request->get('answer')]); $answer = $this->answerRepository->findOneBy(['id' => $request->request->get('answer')]);
if (!$answer instanceof Answer) { if (!$answer instanceof Answer) {
throw new BadRequestHttpException('Invalid Answer ID'); throw new BadRequestHttpException('Invalid Answer ID');
@@ -118,7 +114,7 @@ final class QuizController extends AbstractController
} }
// TODO: Extract getting next question logic to a service // TODO: Extract getting next question logic to a service
$question = $questionRepository->findNextQuestionForCandidate($candidate); $question = $this->questionRepository->findNextQuestionForCandidate($candidate);
// Keep creating flash here based on the return type of service call // Keep creating flash here based on the return type of service call
if (!$question instanceof Question) { if (!$question instanceof Question) {
@@ -127,7 +123,7 @@ final class QuizController extends AbstractController
return $this->redirectToRoute('tvdt_quiz_enter_name', ['seasonCode' => $season->seasonCode]); return $this->redirectToRoute('tvdt_quiz_enter_name', ['seasonCode' => $season->seasonCode]);
} }
$quizCandidateRepository->createIfNotExist($quiz, $candidate); $this->quizCandidateRepository->createIfNotExist($quiz, $candidate);
// end of extracting getting next question logic // end of extracting getting next question logic
return $this->render('quiz/question.twig', ['candidate' => $candidate, 'question' => $question, 'season' => $season]); return $this->render('quiz/question.twig', ['candidate' => $candidate, 'question' => $question, 'season' => $season]);

View File

@@ -9,6 +9,7 @@ use Psr\Log\LoggerInterface;
use Symfony\Bridge\Twig\Mime\TemplatedEmail; use Symfony\Bridge\Twig\Mime\TemplatedEmail;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Bundle\SecurityBundle\Security; use Symfony\Bundle\SecurityBundle\Security;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Mailer\Exception\TransportExceptionInterface; use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
@@ -23,15 +24,12 @@ use Tvdt\Security\EmailVerifier;
final class RegistrationController extends AbstractController final class RegistrationController extends AbstractController
{ {
public function __construct(private readonly EmailVerifier $emailVerifier, private readonly TranslatorInterface $translator) {} public function __construct(private readonly EmailVerifier $emailVerifier, private readonly TranslatorInterface $translator, private readonly UserPasswordHasherInterface $userPasswordHasher, private readonly Security $security, private readonly LoggerInterface $logger, private readonly UserRepository $userRepository) {}
#[Route('/register', name: 'tvdt_register')] #[Route('/register', name: 'tvdt_register')]
public function register( public function register(
Request $request, Request $request,
UserPasswordHasherInterface $userPasswordHasher,
Security $security,
EntityManagerInterface $entityManager, EntityManagerInterface $entityManager,
LoggerInterface $logger,
): Response { ): Response {
$user = new User(); $user = new User();
$form = $this->createForm(RegistrationFormType::class, $user); $form = $this->createForm(RegistrationFormType::class, $user);
@@ -41,7 +39,7 @@ final class RegistrationController extends AbstractController
/** @var string $plainPassword */ /** @var string $plainPassword */
$plainPassword = $form->get('plainPassword')->getData(); $plainPassword = $form->get('plainPassword')->getData();
$user->password = $userPasswordHasher->hashPassword($user, $plainPassword); $user->password = $this->userPasswordHasher->hashPassword($user, $plainPassword);
$entityManager->persist($user); $entityManager->persist($user);
$entityManager->flush(); $entityManager->flush();
@@ -55,10 +53,10 @@ final class RegistrationController extends AbstractController
->htmlTemplate('backoffice/registration/confirmation_email.html.twig'), ->htmlTemplate('backoffice/registration/confirmation_email.html.twig'),
); );
} catch (TransportExceptionInterface $e) { } catch (TransportExceptionInterface $e) {
$logger->error($e->getMessage()); $this->logger->error($e->getMessage());
} }
$response = $security->login($user, 'form_login', 'main'); $response = $this->security->login($user, 'form_login', 'main');
\assert($response instanceof Response); \assert($response instanceof Response);
return $response; return $response;
@@ -70,7 +68,7 @@ final class RegistrationController extends AbstractController
} }
#[Route('/verify/email', name: 'tvdt_verify_email')] #[Route('/verify/email', name: 'tvdt_verify_email')]
public function verifyUserEmail(Request $request, TranslatorInterface $translator, UserRepository $userRepository): Response public function verifyUserEmail(Request $request): RedirectResponse
{ {
$id = $request->query->get('id'); $id = $request->query->get('id');
@@ -78,7 +76,7 @@ final class RegistrationController extends AbstractController
return $this->redirectToRoute('tvdt_register'); return $this->redirectToRoute('tvdt_register');
} }
$user = $userRepository->find($id); $user = $this->userRepository->find($id);
if (null === $user) { if (null === $user) {
return $this->redirectToRoute('tvdt_register'); return $this->redirectToRoute('tvdt_register');
@@ -88,7 +86,7 @@ final class RegistrationController extends AbstractController
try { try {
$this->emailVerifier->handleEmailConfirmation($request, $user); $this->emailVerifier->handleEmailConfirmation($request, $user);
} catch (VerifyEmailExceptionInterface $verifyEmailException) { } catch (VerifyEmailExceptionInterface $verifyEmailException) {
$this->addFlash('verify_email_error', $translator->trans($verifyEmailException->getReason(), [], 'VerifyEmailBundle')); $this->addFlash('verify_email_error', $this->translator->trans($verifyEmailException->getReason(), [], 'VerifyEmailBundle'));
return $this->redirectToRoute('tvdt_register'); return $this->redirectToRoute('tvdt_register');
} }

View File

@@ -55,6 +55,10 @@ class Elimination
public function getScreenColour(?string $name): ?string public function getScreenColour(?string $name): ?string
{ {
if (null === $name) {
return null;
}
return $this->data[$name] ?? null; return $this->data[$name] ?? null;
} }
} }

View File

@@ -7,11 +7,18 @@ namespace Tvdt\Enum;
enum FlashType: string enum FlashType: string
{ {
case Primary = 'primary'; case Primary = 'primary';
case Secondary = 'secondary'; case Secondary = 'secondary';
case Success = 'success'; case Success = 'success';
case Danger = 'danger'; case Danger = 'danger';
case Warning = 'warning'; case Warning = 'warning';
case Info = 'info'; case Info = 'info';
case Light = 'light'; case Light = 'light';
case Dark = 'dark'; case Dark = 'dark';
} }

View File

@@ -56,6 +56,7 @@ class QuizRepository extends ServiceEntityRepository
$em->rollback(); $em->rollback();
throw new ErrorClearingQuizException(previous: $throwable); throw new ErrorClearingQuizException(previous: $throwable);
} }
// @codeCoverageIgnoreEnd // @codeCoverageIgnoreEnd
$em->commit(); $em->commit();

View File

@@ -84,26 +84,27 @@
] ]
}, },
"phpunit/phpunit": { "phpunit/phpunit": {
"version": "12.1", "version": "12.4",
"recipe": { "recipe": {
"repo": "github.com/symfony/recipes", "repo": "github.com/symfony/recipes",
"branch": "main", "branch": "main",
"version": "10.0", "version": "11.1",
"ref": "bb22cf8d8c554a623b427d5f3416b538f5525233" "ref": "1117deb12541f35793eec9fff7494d7aa12283fc"
}, },
"files": [ "files": [
".env.test", ".env.test",
"bin/phpunit",
"phpunit.dist.xml", "phpunit.dist.xml",
"tests/bootstrap.php" "tests/bootstrap.php"
] ]
}, },
"sentry/sentry-symfony": { "sentry/sentry-symfony": {
"version": "5.2", "version": "5.6",
"recipe": { "recipe": {
"repo": "github.com/symfony/recipes-contrib", "repo": "github.com/symfony/recipes-contrib",
"branch": "main", "branch": "main",
"version": "5.0", "version": "5.0",
"ref": "c3decefe8a11a5da43adaf827a6cd66695586113" "ref": "b6cb4b34429dadecd7187852123be19d628fa37a"
}, },
"files": [ "files": [
"config/packages/sentry.yaml" "config/packages/sentry.yaml"

View File

@@ -8,30 +8,33 @@ use PHPUnit\Framework\TestCase;
use Safe\Exceptions\UrlException; use Safe\Exceptions\UrlException;
use Tvdt\Helpers\Base64; use Tvdt\Helpers\Base64;
class Base64Test extends TestCase final class Base64Test extends TestCase
{ {
public function testBase64UrlEncode() { public function testBase64UrlEncode(): void
$this->assertEquals('TWFyaWpu', Base64::base64UrlEncode('Marijn')); {
$this->assertEquals('UGhpbGluZQ', Base64::base64UrlEncode('Philine')); $this->assertSame('TWFyaWpu', Base64::base64UrlEncode('Marijn'));
$this->assertSame('UGhpbGluZQ', Base64::base64UrlEncode('Philine'));
$this->assertEquals('_g', Base64::base64UrlEncode(chr(254)));
$this->assertEquals('-g', Base64::base64UrlEncode(chr(250)));
$this->assertSame('_g', Base64::base64UrlEncode(\chr(254)));
$this->assertSame('-g', Base64::base64UrlEncode(\chr(250)));
} }
public function testBase64UrlDecode() { public function testBase64UrlDecode(): void
$this->assertEquals('Marijn', Base64::base64UrlDecode('TWFyaWpu')); {
$this->assertEquals('Philine', Base64::base64UrlDecode('UGhpbGluZQ')); $this->assertSame('Marijn', Base64::base64UrlDecode('TWFyaWpu'));
$this->assertSame('Philine', Base64::base64UrlDecode('UGhpbGluZQ'));
$this->assertEquals(chr(254), Base64::base64UrlDecode('_g')); $this->assertSame(\chr(254), Base64::base64UrlDecode('_g'));
$this->assertEquals(chr(250), Base64::base64UrlDecode('-g')); $this->assertSame(\chr(250), Base64::base64UrlDecode('-g'));
} }
public function testBase64UrlDecodeCanHandlePadding() { public function testBase64UrlDecodeCanHandlePadding(): void
$this->assertEquals('Philine', Base64::base64UrlDecode('UGhpbGluZQ==')); {
$this->assertSame('Philine', Base64::base64UrlDecode('UGhpbGluZQ=='));
} }
public function testBase64UrlDecodeThrowsExceptionOnInvalidInput() { public function testBase64UrlDecodeThrowsExceptionOnInvalidInput(): void
{
$this->expectException(UrlException::class); $this->expectException(UrlException::class);
Base64::base64UrlDecode('Philine=='); Base64::base64UrlDecode('Philine==');
} }