1 Commits

Author SHA1 Message Date
dependabot[bot]
2201781185 Bump rector/rector from 2.1.7 to 2.2.1
Bumps [rector/rector](https://github.com/rectorphp/rector) from 2.1.7 to 2.2.1.
- [Release notes](https://github.com/rectorphp/rector/releases)
- [Commits](https://github.com/rectorphp/rector/compare/2.1.7...2.2.1)

---
updated-dependencies:
- dependency-name: rector/rector
  dependency-version: 2.2.1
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-06 23:32:01 +00:00
91 changed files with 2573 additions and 5303 deletions

1
.env
View File

@@ -36,4 +36,3 @@ MAILER_DSN=null://null
###> sentry/sentry-symfony ### ###> sentry/sentry-symfony ###
SENTRY_DSN= SENTRY_DSN=
###< sentry/sentry-symfony ### ###< sentry/sentry-symfony ###
XDEBUG_MODE=coverage

View File

@@ -1,3 +1,4 @@
# 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

View File

@@ -8,8 +8,4 @@ updates:
- package-ecosystem: "composer" # See documentation for possible values - package-ecosystem: "composer" # See documentation for possible values
directory: "/" # Location of package manifests directory: "/" # Location of package manifests
schedule: schedule:
interval: "daily" interval: "weekly"
- package-ecosystem: "docker"
directtory: "/"
schedule:
interval: "daily"

View File

@@ -13,10 +13,6 @@ concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true cancel-in-progress: true
permissions:
contents: read
packages: write
jobs: jobs:
tests: tests:
name: Tests name: Tests
@@ -57,68 +53,21 @@ jobs:
run: docker compose exec -T php bin/console -e test doctrine:database:create run: docker compose exec -T php bin/console -e test doctrine:database:create
- name: Run migrations - name: Run migrations
run: docker compose exec -T php bin/console -e test doctrine:migrations:migrate --no-interaction run: docker compose exec -T php bin/console -e test doctrine:migrations:migrate --no-interaction
- name: Load fixtures
run: docker compose exec -T php bin/console -e test doctrine:fixtures:load --no-interaction --group=test
- name: Run PHPUnit - name: Run PHPUnit
run: docker compose exec -T php vendor/bin/phpunit run: docker compose exec -T php vendor/bin/phpunit
- name: Doctrine Schema Validator - name: Doctrine Schema Validator
run: docker compose exec -T php bin/console -e test doctrine:schema:validate run: docker compose exec -T php bin/console -e test doctrine:schema:validate
deploy:
build-deploy: name: Deploy
name: Build and deploy to ${{ startsWith(github.ref, 'refs/tags/') && 'production' || (github.ref == 'refs/heads/main' && 'acceptance' || '') }}
environment: environment:
name: ${{ startsWith(github.ref, 'refs/tags/') && 'production' || (github.ref == 'refs/heads/main' && 'acceptance' || '') }} name: ${{ startsWith(github.ref, 'refs/tags/') && 'production' || (github.ref == 'refs/heads/main' && 'acceptance' || '') }}
url: ${{ vars.URL }} url: ${{ vars.URL }}
needs: tests needs: tests
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: (github.ref == 'refs/heads/main' && false) || startsWith(github.ref, 'refs/tags/') if: startsWith(github.ref, 'refs/tags/')
steps: steps:
- name: Checkout - shell: bash
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
run: |
REPO_LOWER=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
TAG="${GITHUB_REF#refs/tags/}"
{
echo "tag=$TAG"
echo "full_name=ghcr.io/${REPO_LOWER}:$TAG"
} >> "$GITHUB_OUTPUT"
else
SHORT_SHA=$(git rev-parse --short HEAD)
{
echo "tag=$SHORT_SHA"
echo "full_name=ghcr.io/${REPO_LOWER}:$SHORT_SHA"
} >> "$GITHUB_OUTPUT"
fi
- name: Build and Push Docker images
uses: docker/bake-action@v5
with:
pull: true
push: true
files: |
compose.yaml
compose.build.yaml
set: |
*.cache-from=type=gha,scope=${{github.ref}}
*.cache-from=type=gha,scope=refs/heads/main
*.cache-to=type=gha,scope=${{github.ref}},mode=max
*.tags=${{ steps.meta.outputs.full_name }}
- name: Trigger Portainer Deployment
shell: bash
env: env:
PORTAINER_WEBHOOK: ${{secrets.PORTAINER_WEBHOOK}} PORTAINER_WEBHOOK: ${{secrets.PORTAINER_WEBHOOK}}
run: | run: |
curl -v -X POST "$PORTAINER_WEBHOOK"?IMAGE_TAG=${{steps.meta.outputs.tag}} --fail-with-body curl -v -X POST "$PORTAINER_WEBHOOK"

View File

@@ -164,10 +164,6 @@
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/ux-turbo" /> <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/ux-turbo" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-uuid" /> <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-uuid" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/brevo-mailer" /> <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/brevo-mailer" />
<excludeFolder url="file://$MODULE_DIR$/vendor/martin-georgiev/postgresql-for-doctrine" />
<excludeFolder url="file://$MODULE_DIR$/vendor/dama/doctrine-test-bundle" />
<excludeFolder url="file://$MODULE_DIR$/vendor/gedmo/doctrine-extensions" />
<excludeFolder url="file://$MODULE_DIR$/vendor/stof/doctrine-extensions-bundle" />
</content> </content>
<orderEntry type="inheritedJdk" /> <orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />

View File

@@ -5,7 +5,7 @@
<tool tool_name="PHPUnit"> <tool tool_name="PHPUnit">
<cache> <cache>
<versions> <versions>
<info id="interpreter-96512cb2-7b9e-4e1d-bfa2-bf7f3be424c8" version="12.4.1" /> <info id="interpreter-96512cb2-7b9e-4e1d-bfa2-bf7f3be424c8" version="12.1.2" />
</versions> </versions>
</cache> </cache>
</tool> </tool>

320
.idea/php.xml generated
View File

@@ -36,169 +36,165 @@
</component> </component>
<component name="PhpIncludePathManager"> <component name="PhpIncludePathManager">
<include_path> <include_path>
<path value="$PROJECT_DIR$/vendor/composer" />
<path value="$PROJECT_DIR$/vendor/webmozart/assert" />
<path value="$PROJECT_DIR$/vendor/martin-georgiev/postgresql-for-doctrine" />
<path value="$PROJECT_DIR$/vendor/dama/doctrine-test-bundle" />
<path value="$PROJECT_DIR$/vendor/staabm/side-effects-detector" />
<path value="$PROJECT_DIR$/vendor/psr/http-client" />
<path value="$PROJECT_DIR$/vendor/psr/container" />
<path value="$PROJECT_DIR$/vendor/psr/simple-cache" />
<path value="$PROJECT_DIR$/vendor/psr/log" />
<path value="$PROJECT_DIR$/vendor/psr/cache" />
<path value="$PROJECT_DIR$/vendor/psr/http-message" />
<path value="$PROJECT_DIR$/vendor/psr/event-dispatcher" />
<path value="$PROJECT_DIR$/vendor/symfony/cache" />
<path value="$PROJECT_DIR$/vendor/symfony/validator" />
<path value="$PROJECT_DIR$/vendor/symfony/asset" />
<path value="$PROJECT_DIR$/vendor/fidry/cpu-core-counter" />
<path value="$PROJECT_DIR$/vendor/symfony/ux-turbo" />
<path value="$PROJECT_DIR$/vendor/symfony/form" />
<path value="$PROJECT_DIR$/vendor/vincentlanglet/twig-cs-fixer" />
<path value="$PROJECT_DIR$/vendor/symfony/dotenv" />
<path value="$PROJECT_DIR$/vendor/symfony/serializer" />
<path value="$PROJECT_DIR$/vendor/rector/rector" />
<path value="$PROJECT_DIR$/vendor/phpstan/phpdoc-parser" />
<path value="$PROJECT_DIR$/vendor/phpstan/extension-installer" />
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-intl-icu" />
<path value="$PROJECT_DIR$/vendor/symfonycasts/sass-bundle" />
<path value="$PROJECT_DIR$/vendor/symfony/framework-bundle" />
<path value="$PROJECT_DIR$/vendor/symfonycasts/verify-email-bundle" />
<path value="$PROJECT_DIR$/vendor/psr/http-factory" />
<path value="$PROJECT_DIR$/vendor/phpstan/phpstan-doctrine" />
<path value="$PROJECT_DIR$/vendor/psr/clock" />
<path value="$PROJECT_DIR$/vendor/phpstan/phpstan" />
<path value="$PROJECT_DIR$/vendor/theseer/tokenizer" />
<path value="$PROJECT_DIR$/vendor/phpstan/phpstan-phpunit" />
<path value="$PROJECT_DIR$/vendor/phpstan/phpstan-symfony" />
<path value="$PROJECT_DIR$/vendor/symfony/mailer" />
<path value="$PROJECT_DIR$/vendor/symfony/brevo-mailer" />
<path value="$PROJECT_DIR$/vendor/symfony/options-resolver" />
<path value="$PROJECT_DIR$/vendor/symfony/filesystem" />
<path value="$PROJECT_DIR$/vendor/symfony/runtime" />
<path value="$PROJECT_DIR$/vendor/symfony/event-dispatcher" />
<path value="$PROJECT_DIR$/vendor/symfony/var-dumper" />
<path value="$PROJECT_DIR$/vendor/symfony/phpunit-bridge" />
<path value="$PROJECT_DIR$/vendor/symfony/security-http" />
<path value="$PROJECT_DIR$/vendor/symfony/config" />
<path value="$PROJECT_DIR$/vendor/symfony/asset-mapper" />
<path value="$PROJECT_DIR$/vendor/symfony/uid" />
<path value="$PROJECT_DIR$/vendor/symfony/intl" />
<path value="$PROJECT_DIR$/vendor/symfony/security-bundle" />
<path value="$PROJECT_DIR$/vendor/symfony/translation-contracts" />
<path value="$PROJECT_DIR$/vendor/symfony/translation" />
<path value="$PROJECT_DIR$/vendor/symfony/http-client" />
<path value="$PROJECT_DIR$/vendor/friendsofphp/php-cs-fixer" />
<path value="$PROJECT_DIR$/vendor/gedmo/doctrine-extensions" />
<path value="$PROJECT_DIR$/vendor/symfony/finder" />
<path value="$PROJECT_DIR$/vendor/symfony/psr-http-message-bridge" />
<path value="$PROJECT_DIR$/vendor/symfony/stopwatch" />
<path value="$PROJECT_DIR$/vendor/masterminds/html5" />
<path value="$PROJECT_DIR$/vendor/symfony/event-dispatcher-contracts" />
<path value="$PROJECT_DIR$/vendor/symfony/twig-bundle" />
<path value="$PROJECT_DIR$/vendor/symfony/property-access" />
<path value="$PROJECT_DIR$/vendor/symfony/web-profiler-bundle" />
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-uuid" />
<path value="$PROJECT_DIR$/vendor/symfony/css-selector" />
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-intl-normalizer" />
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-intl-idn" />
<path value="$PROJECT_DIR$/vendor/symfony/security-csrf" />
<path value="$PROJECT_DIR$/vendor/symfony/twig-bridge" />
<path value="$PROJECT_DIR$/vendor/symfony/maker-bundle" />
<path value="$PROJECT_DIR$/vendor/symfony/var-exporter" />
<path value="$PROJECT_DIR$/vendor/symfony/doctrine-bridge" />
<path value="$PROJECT_DIR$/vendor/symfony/error-handler" />
<path value="$PROJECT_DIR$/vendor/symfony/flex" />
<path value="$PROJECT_DIR$/vendor/symfony/property-info" />
<path value="$PROJECT_DIR$/vendor/symfony/http-client-contracts" />
<path value="$PROJECT_DIR$/vendor/symfony/http-foundation" />
<path value="$PROJECT_DIR$/vendor/symfony/type-info" />
<path value="$PROJECT_DIR$/vendor/guzzlehttp/psr7" />
<path value="$PROJECT_DIR$/vendor/symfony/deprecation-contracts" />
<path value="$PROJECT_DIR$/vendor/symfony/security-core" />
<path value="$PROJECT_DIR$/vendor/symfony/service-contracts" />
<path value="$PROJECT_DIR$/vendor/symfony/routing" />
<path value="$PROJECT_DIR$/vendor/symfony/yaml" />
<path value="$PROJECT_DIR$/vendor/symfony/http-kernel" />
<path value="$PROJECT_DIR$/vendor/symfony/string" />
<path value="$PROJECT_DIR$/vendor/symfony/mime" />
<path value="$PROJECT_DIR$/vendor/markbaker/matrix" />
<path value="$PROJECT_DIR$/vendor/markbaker/complex" />
<path value="$PROJECT_DIR$/vendor/ralouphie/getallheaders" />
<path value="$PROJECT_DIR$/vendor/nikic/php-parser" />
<path value="$PROJECT_DIR$/vendor/symfony/process" />
<path value="$PROJECT_DIR$/vendor/symfony/password-hasher" />
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-intl-grapheme" />
<path value="$PROJECT_DIR$/vendor/symfony/console" />
<path value="$PROJECT_DIR$/vendor/symfony/dependency-injection" />
<path value="$PROJECT_DIR$/vendor/symfony/cache-contracts" />
<path value="$PROJECT_DIR$/vendor/symfony/clock" />
<path value="$PROJECT_DIR$/vendor/symfony/stimulus-bundle" />
<path value="$PROJECT_DIR$/vendor/phpdocumentor/type-resolver" />
<path value="$PROJECT_DIR$/vendor/phpdocumentor/reflection-common" />
<path value="$PROJECT_DIR$/vendor/phpdocumentor/reflection-docblock" />
<path value="$PROJECT_DIR$/vendor/phpunit/php-code-coverage" />
<path value="$PROJECT_DIR$/vendor/phpunit/php-text-template" />
<path value="$PROJECT_DIR$/vendor/phpunit/php-file-iterator" />
<path value="$PROJECT_DIR$/vendor/phpunit/php-invoker" />
<path value="$PROJECT_DIR$/vendor/phar-io/manifest" />
<path value="$PROJECT_DIR$/vendor/phpoffice/phpspreadsheet" />
<path value="$PROJECT_DIR$/vendor/phpunit/phpunit" />
<path value="$PROJECT_DIR$/vendor/phar-io/version" />
<path value="$PROJECT_DIR$/vendor/phpunit/php-timer" />
<path value="$PROJECT_DIR$/vendor/clue/ndjson-react" />
<path value="$PROJECT_DIR$/vendor/react/socket" />
<path value="$PROJECT_DIR$/vendor/react/dns" />
<path value="$PROJECT_DIR$/vendor/react/child-process" />
<path value="$PROJECT_DIR$/vendor/react/cache" />
<path value="$PROJECT_DIR$/vendor/react/event-loop" />
<path value="$PROJECT_DIR$/vendor/react/promise" />
<path value="$PROJECT_DIR$/vendor/react/stream" /> <path value="$PROJECT_DIR$/vendor/react/stream" />
<path value="$PROJECT_DIR$/vendor/myclabs/deep-copy" /> <path value="$PROJECT_DIR$/vendor/react/promise" />
<path value="$PROJECT_DIR$/vendor/runtime/frankenphp-symfony" /> <path value="$PROJECT_DIR$/vendor/react/event-loop" />
<path value="$PROJECT_DIR$/vendor/twig/twig" /> <path value="$PROJECT_DIR$/vendor/react/cache" />
<path value="$PROJECT_DIR$/vendor/twig/intl-extra" /> <path value="$PROJECT_DIR$/vendor/react/child-process" />
<path value="$PROJECT_DIR$/vendor/thecodingmachine/phpstan-safe-rule" />
<path value="$PROJECT_DIR$/vendor/thecodingmachine/safe" />
<path value="$PROJECT_DIR$/vendor/twig/extra-bundle" />
<path value="$PROJECT_DIR$/vendor/sebastian/global-state" />
<path value="$PROJECT_DIR$/vendor/sebastian/comparator" />
<path value="$PROJECT_DIR$/vendor/sebastian/object-reflector" />
<path value="$PROJECT_DIR$/vendor/sebastian/object-enumerator" />
<path value="$PROJECT_DIR$/vendor/maennchen/zipstream-php" />
<path value="$PROJECT_DIR$/vendor/sebastian/exporter" />
<path value="$PROJECT_DIR$/vendor/sebastian/version" />
<path value="$PROJECT_DIR$/vendor/sebastian/type" />
<path value="$PROJECT_DIR$/vendor/sebastian/environment" />
<path value="$PROJECT_DIR$/vendor/sebastian/cli-parser" />
<path value="$PROJECT_DIR$/vendor/sebastian/diff" />
<path value="$PROJECT_DIR$/vendor/sebastian/complexity" />
<path value="$PROJECT_DIR$/vendor/sebastian/lines-of-code" />
<path value="$PROJECT_DIR$/vendor/sebastian/recursion-context" />
<path value="$PROJECT_DIR$/vendor/sentry/sentry" />
<path value="$PROJECT_DIR$/vendor/sentry/sentry-symfony" />
<path value="$PROJECT_DIR$/vendor/egulias/email-validator" />
<path value="$PROJECT_DIR$/vendor/jean85/pretty-package-versions" /> <path value="$PROJECT_DIR$/vendor/jean85/pretty-package-versions" />
<path value="$PROJECT_DIR$/vendor/doctrine/sql-formatter" /> <path value="$PROJECT_DIR$/vendor/react/dns" />
<path value="$PROJECT_DIR$/vendor/doctrine/collections" /> <path value="$PROJECT_DIR$/vendor/react/socket" />
<path value="$PROJECT_DIR$/vendor/doctrine/doctrine-bundle" /> <path value="$PROJECT_DIR$/vendor/sentry/sentry" />
<path value="$PROJECT_DIR$/vendor/doctrine/deprecations" /> <path value="$PROJECT_DIR$/vendor/staabm/side-effects-detector" />
<path value="$PROJECT_DIR$/vendor/doctrine/instantiator" /> <path value="$PROJECT_DIR$/vendor/rector/rector" />
<path value="$PROJECT_DIR$/vendor/doctrine/doctrine-fixtures-bundle" /> <path value="$PROJECT_DIR$/vendor/sentry/sentry-symfony" />
<path value="$PROJECT_DIR$/vendor/doctrine/event-manager" /> <path value="$PROJECT_DIR$/vendor/phar-io/manifest" />
<path value="$PROJECT_DIR$/vendor/doctrine/orm" /> <path value="$PROJECT_DIR$/vendor/phar-io/version" />
<path value="$PROJECT_DIR$/vendor/doctrine/dbal" /> <path value="$PROJECT_DIR$/vendor/egulias/email-validator" />
<path value="$PROJECT_DIR$/vendor/doctrine/lexer" /> <path value="$PROJECT_DIR$/vendor/myclabs/deep-copy" />
<path value="$PROJECT_DIR$/vendor/doctrine/persistence" /> <path value="$PROJECT_DIR$/vendor/phpstan/phpstan-symfony" />
<path value="$PROJECT_DIR$/vendor/doctrine/inflector" /> <path value="$PROJECT_DIR$/vendor/phpstan/phpstan-phpunit" />
<path value="$PROJECT_DIR$/vendor/doctrine/doctrine-migrations-bundle" /> <path value="$PROJECT_DIR$/vendor/phpstan/phpstan" />
<path value="$PROJECT_DIR$/vendor/doctrine/data-fixtures" /> <path value="$PROJECT_DIR$/vendor/phpstan/phpstan-doctrine" />
<path value="$PROJECT_DIR$/vendor/doctrine/migrations" /> <path value="$PROJECT_DIR$/vendor/phpunit/php-timer" />
<path value="$PROJECT_DIR$/vendor/evenement/evenement" /> <path value="$PROJECT_DIR$/vendor/phpunit/phpunit" />
<path value="$PROJECT_DIR$/vendor/stof/doctrine-extensions-bundle" /> <path value="$PROJECT_DIR$/vendor/phpstan/extension-installer" />
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-php84" /> <path value="$PROJECT_DIR$/vendor/phpstan/phpdoc-parser" />
<path value="$PROJECT_DIR$/vendor/symfony/dom-crawler" /> <path value="$PROJECT_DIR$/vendor/phpunit/php-invoker" />
<path value="$PROJECT_DIR$/vendor/phpunit/php-file-iterator" />
<path value="$PROJECT_DIR$/vendor/phpunit/php-text-template" />
<path value="$PROJECT_DIR$/vendor/phpunit/php-code-coverage" />
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-intl-icu" />
<path value="$PROJECT_DIR$/vendor/symfony/form" />
<path value="$PROJECT_DIR$/vendor/runtime/frankenphp-symfony" />
<path value="$PROJECT_DIR$/vendor/symfony/framework-bundle" />
<path value="$PROJECT_DIR$/vendor/symfony/cache" />
<path value="$PROJECT_DIR$/vendor/symfony/serializer" />
<path value="$PROJECT_DIR$/vendor/symfony/dotenv" />
<path value="$PROJECT_DIR$/vendor/symfony/security-bundle" />
<path value="$PROJECT_DIR$/vendor/symfony/intl" />
<path value="$PROJECT_DIR$/vendor/symfony/asset" />
<path value="$PROJECT_DIR$/vendor/symfony/browser-kit" /> <path value="$PROJECT_DIR$/vendor/symfony/browser-kit" />
<path value="$PROJECT_DIR$/vendor/symfony/config" />
<path value="$PROJECT_DIR$/vendor/symfony/security-http" />
<path value="$PROJECT_DIR$/vendor/symfony/translation-contracts" />
<path value="$PROJECT_DIR$/vendor/symfony/event-dispatcher" />
<path value="$PROJECT_DIR$/vendor/symfony/runtime" />
<path value="$PROJECT_DIR$/vendor/symfony/uid" />
<path value="$PROJECT_DIR$/vendor/symfony/asset-mapper" />
<path value="$PROJECT_DIR$/vendor/symfony/mailer" />
<path value="$PROJECT_DIR$/vendor/symfony/filesystem" />
<path value="$PROJECT_DIR$/vendor/symfony/phpunit-bridge" />
<path value="$PROJECT_DIR$/vendor/symfony/var-dumper" />
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-intl-idn" />
<path value="$PROJECT_DIR$/vendor/symfony/maker-bundle" />
<path value="$PROJECT_DIR$/vendor/symfony/options-resolver" />
<path value="$PROJECT_DIR$/vendor/symfony/security-csrf" />
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-intl-normalizer" />
<path value="$PROJECT_DIR$/vendor/symfony/css-selector" />
<path value="$PROJECT_DIR$/vendor/symfony/twig-bridge" />
<path value="$PROJECT_DIR$/vendor/symfony/web-profiler-bundle" />
<path value="$PROJECT_DIR$/vendor/symfony/property-access" />
<path value="$PROJECT_DIR$/vendor/symfony/twig-bundle" />
<path value="$PROJECT_DIR$/vendor/symfony/event-dispatcher-contracts" />
<path value="$PROJECT_DIR$/vendor/symfony/dom-crawler" />
<path value="$PROJECT_DIR$/vendor/symfony/http-client" />
<path value="$PROJECT_DIR$/vendor/symfony/stopwatch" />
<path value="$PROJECT_DIR$/vendor/symfony/finder" />
<path value="$PROJECT_DIR$/vendor/symfony/yaml" />
<path value="$PROJECT_DIR$/vendor/symfony/mime" />
<path value="$PROJECT_DIR$/vendor/symfony/psr-http-message-bridge" />
<path value="$PROJECT_DIR$/vendor/symfony/http-kernel" />
<path value="$PROJECT_DIR$/vendor/symfony/deprecation-contracts" />
<path value="$PROJECT_DIR$/vendor/symfony/routing" />
<path value="$PROJECT_DIR$/vendor/symfony/string" />
<path value="$PROJECT_DIR$/vendor/symfony/security-core" />
<path value="$PROJECT_DIR$/vendor/symfony/property-info" />
<path value="$PROJECT_DIR$/vendor/symfony/type-info" />
<path value="$PROJECT_DIR$/vendor/symfony/service-contracts" />
<path value="$PROJECT_DIR$/vendor/symfony/http-client-contracts" />
<path value="$PROJECT_DIR$/vendor/symfony/var-exporter" />
<path value="$PROJECT_DIR$/vendor/symfony/flex" />
<path value="$PROJECT_DIR$/vendor/symfony/http-foundation" />
<path value="$PROJECT_DIR$/vendor/symfony/doctrine-bridge" />
<path value="$PROJECT_DIR$/vendor/symfony/dependency-injection" />
<path value="$PROJECT_DIR$/vendor/symfony/clock" />
<path value="$PROJECT_DIR$/vendor/symfony/error-handler" />
<path value="$PROJECT_DIR$/vendor/symfony/cache-contracts" />
<path value="$PROJECT_DIR$/vendor/symfony/console" />
<path value="$PROJECT_DIR$/vendor/symfony/password-hasher" />
<path value="$PROJECT_DIR$/vendor/symfony/process" />
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-intl-grapheme" />
<path value="$PROJECT_DIR$/vendor/theseer/tokenizer" />
<path value="$PROJECT_DIR$/vendor/doctrine/doctrine-migrations-bundle" />
<path value="$PROJECT_DIR$/vendor/doctrine/lexer" />
<path value="$PROJECT_DIR$/vendor/doctrine/dbal" />
<path value="$PROJECT_DIR$/vendor/doctrine/migrations" />
<path value="$PROJECT_DIR$/vendor/doctrine/data-fixtures" />
<path value="$PROJECT_DIR$/vendor/doctrine/doctrine-fixtures-bundle" />
<path value="$PROJECT_DIR$/vendor/doctrine/instantiator" />
<path value="$PROJECT_DIR$/vendor/doctrine/inflector" />
<path value="$PROJECT_DIR$/vendor/doctrine/persistence" />
<path value="$PROJECT_DIR$/vendor/doctrine/collections" />
<path value="$PROJECT_DIR$/vendor/doctrine/sql-formatter" />
<path value="$PROJECT_DIR$/vendor/doctrine/orm" />
<path value="$PROJECT_DIR$/vendor/doctrine/event-manager" />
<path value="$PROJECT_DIR$/vendor/evenement/evenement" />
<path value="$PROJECT_DIR$/vendor/doctrine/deprecations" />
<path value="$PROJECT_DIR$/vendor/doctrine/doctrine-bundle" />
<path value="$PROJECT_DIR$/vendor/markbaker/matrix" />
<path value="$PROJECT_DIR$/vendor/phpoffice/phpspreadsheet" />
<path value="$PROJECT_DIR$/vendor/maennchen/zipstream-php" />
<path value="$PROJECT_DIR$/vendor/markbaker/complex" />
<path value="$PROJECT_DIR$/vendor/sebastian/global-state" />
<path value="$PROJECT_DIR$/vendor/sebastian/object-enumerator" />
<path value="$PROJECT_DIR$/vendor/ralouphie/getallheaders" />
<path value="$PROJECT_DIR$/vendor/sebastian/comparator" />
<path value="$PROJECT_DIR$/vendor/sebastian/diff" />
<path value="$PROJECT_DIR$/vendor/sebastian/recursion-context" />
<path value="$PROJECT_DIR$/vendor/sebastian/object-reflector" />
<path value="$PROJECT_DIR$/vendor/sebastian/complexity" />
<path value="$PROJECT_DIR$/vendor/sebastian/version" />
<path value="$PROJECT_DIR$/vendor/sebastian/cli-parser" />
<path value="$PROJECT_DIR$/vendor/sebastian/lines-of-code" />
<path value="$PROJECT_DIR$/vendor/sebastian/type" />
<path value="$PROJECT_DIR$/vendor/webmozart/assert" />
<path value="$PROJECT_DIR$/vendor/guzzlehttp/psr7" />
<path value="$PROJECT_DIR$/vendor/sebastian/environment" />
<path value="$PROJECT_DIR$/vendor/sebastian/exporter" />
<path value="$PROJECT_DIR$/vendor/symfonycasts/verify-email-bundle" />
<path value="$PROJECT_DIR$/vendor/symfonycasts/sass-bundle" />
<path value="$PROJECT_DIR$/vendor/masterminds/html5" />
<path value="$PROJECT_DIR$/vendor/friendsofphp/php-cs-fixer" />
<path value="$PROJECT_DIR$/vendor/phpdocumentor/reflection-docblock" />
<path value="$PROJECT_DIR$/vendor/vincentlanglet/twig-cs-fixer" />
<path value="$PROJECT_DIR$/vendor/phpdocumentor/reflection-common" />
<path value="$PROJECT_DIR$/vendor/phpdocumentor/type-resolver" />
<path value="$PROJECT_DIR$/vendor/thecodingmachine/safe" />
<path value="$PROJECT_DIR$/vendor/thecodingmachine/phpstan-safe-rule" />
<path value="$PROJECT_DIR$/vendor/composer" />
<path value="$PROJECT_DIR$/vendor/psr/http-message" />
<path value="$PROJECT_DIR$/vendor/psr/container" />
<path value="$PROJECT_DIR$/vendor/psr/cache" />
<path value="$PROJECT_DIR$/vendor/psr/event-dispatcher" />
<path value="$PROJECT_DIR$/vendor/psr/simple-cache" />
<path value="$PROJECT_DIR$/vendor/psr/clock" />
<path value="$PROJECT_DIR$/vendor/psr/http-client" />
<path value="$PROJECT_DIR$/vendor/psr/log" />
<path value="$PROJECT_DIR$/vendor/twig/extra-bundle" />
<path value="$PROJECT_DIR$/vendor/twig/intl-extra" />
<path value="$PROJECT_DIR$/vendor/psr/http-factory" />
<path value="$PROJECT_DIR$/vendor/clue/ndjson-react" />
<path value="$PROJECT_DIR$/vendor/fidry/cpu-core-counter" />
<path value="$PROJECT_DIR$/vendor/nikic/php-parser" />
<path value="$PROJECT_DIR$/vendor/twig/twig" />
<path value="$PROJECT_DIR$/vendor/symfony/ux-turbo" />
<path value="$PROJECT_DIR$/vendor/symfony/stimulus-bundle" />
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-uuid" />
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-php84" />
<path value="$PROJECT_DIR$/vendor/symfony/brevo-mailer" />
<path value="$PROJECT_DIR$/vendor/symfony/translation" />
<path value="$PROJECT_DIR$/vendor/symfony/validator" />
</include_path> </include_path>
</component> </component>
<component name="PhpInterpreters"> <component name="PhpInterpreters">
@@ -277,7 +273,7 @@
</interpreter> </interpreter>
</phpInfoCache> </phpInfoCache>
</component> </component>
<component name="PhpProjectSharedConfiguration" php_language_level="8.5" /> <component name="PhpProjectSharedConfiguration" php_language_level="8.4" />
<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" />
@@ -292,7 +288,7 @@
</component> </component>
<component name="PhpUnit"> <component name="PhpUnit">
<phpunit_settings> <phpunit_settings>
<phpunit_by_interpreter interpreter_id="96512cb2-7b9e-4e1d-bfa2-bf7f3be424c8" bootstrap_file_path="./tests/bootstrap.php" configuration_file_path="./phpunit.dist.xml" custom_loader_path="/app/vendor/autoload.php" phpunit_phar_path="" use_bootstrap_file="true" use_configuration_file="true" /> <phpunit_by_interpreter interpreter_id="96512cb2-7b9e-4e1d-bfa2-bf7f3be424c8" configuration_file_path="phpunit.xml.dist" custom_loader_path="vendor/autoload.php" phpunit_phar_path="" use_configuration_file="true" />
</phpunit_settings> </phpunit_settings>
</component> </component>
<component name="Psalm"> <component name="Psalm">

View File

@@ -9,7 +9,6 @@ $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()
@@ -25,6 +24,7 @@ return new Config()
'no_unreachable_default_argument_value' => true, 'no_unreachable_default_argument_value' => true,
'no_useless_else' => true, 'no_useless_else' => true,
'no_useless_return' => true, 'no_useless_return' => true,
'php_unit_strict' => true,
'phpdoc_line_span' => ['const' => 'single', 'method' => 'single', 'property' => 'single'], 'phpdoc_line_span' => ['const' => 'single', 'method' => 'single', 'property' => 'single'],
'phpdoc_order' => true, 'phpdoc_order' => true,
'single_line_empty_body' => true, 'single_line_empty_body' => true,
@@ -36,5 +36,4 @@ 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.5 AS frankenphp_upstream FROM dunglas/frankenphp:1-php8.4 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
@@ -32,7 +32,7 @@ RUN set -eux; \
opcache \ opcache \
zip \ zip \
gd \ gd \
excimer \ excimer-1.2.3 \
; ;
# https://getcomposer.org/doc/03-cli.md#composer-allow-superuser # https://getcomposer.org/doc/03-cli.md#composer-allow-superuser
@@ -60,19 +60,11 @@ FROM frankenphp_base AS frankenphp_dev
ENV APP_ENV=dev XDEBUG_MODE=off ENV APP_ENV=dev XDEBUG_MODE=off
# hadolint ignore=DL3008
RUN apt-get update && apt-get install -y --no-install-recommends \
bash-completion \
&& rm -rf /var/lib/apt/lists/*
COPY --link frankenphp/console-complete.bash /usr/share/bash-completion/completions/console
COPY --link frankenphp/composer-complete.bash /usr/share/bash-completion/completions/composer
RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini" 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@3.5.0alpha3 \ xdebug \
; ;
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/
@@ -84,8 +76,6 @@ CMD [ "frankenphp", "run", "--config", "/etc/caddy/Caddyfile", "--watch" ]
# Prod FrankenPHP image # Prod FrankenPHP image
FROM frankenphp_base AS frankenphp_prod FROM frankenphp_base AS frankenphp_prod
RUN rm -rf /var/lib/apt/lists/*
ENV APP_ENV=prod ENV APP_ENV=prod
ENV FRANKENPHP_CONFIG="import worker.Caddyfile" ENV FRANKENPHP_CONFIG="import worker.Caddyfile"

View File

@@ -20,7 +20,7 @@ migrate: up
docker compose run --rm php bin/console doctrine:migrations:migrate --no-interaction docker compose run --rm php bin/console doctrine:migrations:migrate --no-interaction
fixtures: fixtures:
docker compose exec php bin/console doctrine:fixtures:load --purge-with-truncate --no-interaction --group=dev docker compose exec php bin/console doctrine:fixtures:load --purge-with-truncate --no-interaction
translations: translations:
docker compose exec php bin/console translation:extract --force --format=xliff --sort=asc --clean nl docker compose exec php bin/console translation:extract --force --format=xliff --sort=asc --clean nl
@@ -39,9 +39,3 @@ phpstan *args:
clean: clean:
docker compose down -v --remove-orphans docker compose down -v --remove-orphans
rm -rf vendor var assets/vendor public/assets public/bundles .php-cs-fixer.cache .twig-cs-fixer.cache rm -rf vendor var assets/vendor public/assets public/bundles .php-cs-fixer.cache .twig-cs-fixer.cache
reload-tests:
@docker compose exec php bin/console --env=test doctrine:database:drop --if-exists --force
@docker compose exec php bin/console --env=test doctrine:database:create
@docker compose exec php bin/console --env=test doctrine:migrations:migrate -n
@docker compose exec php bin/console --env=test doctrine:fixtures:load -n --group=test

View File

@@ -1,5 +0,0 @@
services:
php:
build:
context: .
target: frankenphp_prod

View File

@@ -1,7 +1,9 @@
# Production environment override # Production environment override
services: services:
php: php:
image: ghcr.io/marijndoeve/tijdvoordetest:${IMAGE_TAG} build:
context: .
target: frankenphp_prod
environment: environment:
APP_SECRET: ${APP_SECRET} APP_SECRET: ${APP_SECRET}
MERCURE_PUBLISHER_JWT_KEY: ${CADDY_MERCURE_JWT_SECRET} MERCURE_PUBLISHER_JWT_KEY: ${CADDY_MERCURE_JWT_SECRET}

View File

@@ -6,68 +6,65 @@
"minimum-stability": "stable", "minimum-stability": "stable",
"prefer-stable": true, "prefer-stable": true,
"require": { "require": {
"php": ">=8.5", "php": ">=8.4",
"ext-ctype": "*", "ext-ctype": "*",
"ext-iconv": "*", "ext-iconv": "*",
"doctrine/dbal": "^4.3.4", "doctrine/dbal": "^4.3.3",
"doctrine/doctrine-bundle": "^3.0", "doctrine/doctrine-bundle": "^2.16.2",
"doctrine/doctrine-migrations-bundle": "^3.7.0", "doctrine/doctrine-migrations-bundle": "^3.4.2",
"doctrine/orm": "^3.5.7", "doctrine/orm": "^3.5.2",
"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", "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": "7.4.*", "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": "8.0.*", "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.22.1", "twig/extra-bundle": "^3.21",
"twig/intl-extra": "^3.22.1", "twig/intl-extra": "^3.21",
"twig/twig": "^3.22.0" "twig/twig": "^3.21.1"
}, },
"require-dev": { "require-dev": {
"dama/doctrine-test-bundle": "^8.4", "doctrine/doctrine-fixtures-bundle": "^4.1",
"doctrine/doctrine-fixtures-bundle": "^4.3", "friendsofphp/php-cs-fixer": "^3.88.2",
"friendsofphp/php-cs-fixer": "^3.90.0",
"phpstan/extension-installer": "^1.4.3", "phpstan/extension-installer": "^1.4.3",
"phpstan/phpstan": "^2.1.32", "phpstan/phpstan": "^2.1.30",
"phpstan/phpstan-doctrine": "^2.0.11", "phpstan/phpstan-doctrine": "^2.0.6",
"phpstan/phpstan-phpunit": "^2.0.8", "phpstan/phpstan-phpunit": "^2.0.7",
"phpstan/phpstan-symfony": "^2.0.8", "phpstan/phpstan-symfony": "^2.0.8",
"phpunit/phpunit": "^12.4.4", "phpunit/phpunit": "^12.4.0",
"rector/rector": "^2.2.9", "rector/rector": "^2.1.7",
"roave/security-advisories": "dev-latest", "roave/security-advisories": "dev-latest",
"symfony/browser-kit": "7.4.*", "symfony/browser-kit": "7.3.*",
"symfony/css-selector": "7.4.*", "symfony/css-selector": "7.3.*",
"symfony/maker-bundle": "^1.65.1", "symfony/maker-bundle": "^1.64.0",
"symfony/phpunit-bridge": "7.4.*", "symfony/phpunit-bridge": "7.3.*",
"symfony/stopwatch": "7.4.*", "symfony/stopwatch": "7.3.*",
"symfony/web-profiler-bundle": "7.4.*", "symfony/web-profiler-bundle": "7.3.*",
"thecodingmachine/phpstan-safe-rule": "^1.4.3", "thecodingmachine/phpstan-safe-rule": "^1.4.1",
"vincentlanglet/twig-cs-fixer": "^3.11.0" "vincentlanglet/twig-cs-fixer": "^3.10.0"
}, },
"config": { "config": {
"allow-plugins": { "allow-plugins": {
@@ -100,8 +97,7 @@
"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": {
@@ -122,7 +118,7 @@
"extra": { "extra": {
"symfony": { "symfony": {
"allow-contrib": false, "allow-contrib": false,
"require": "7.4.*", "require": "7.3.*",
"docker": true "docker": true
} }
} }

2614
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -2,12 +2,10 @@
declare(strict_types=1); declare(strict_types=1);
use DAMA\DoctrineTestBundle\DAMADoctrineTestBundle;
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle; use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
use Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle; use Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle;
use Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle; use Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle;
use Sentry\SentryBundle\SentryBundle; use Sentry\SentryBundle\SentryBundle;
use Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle;
use Symfony\Bundle\FrameworkBundle\FrameworkBundle; use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
use Symfony\Bundle\MakerBundle\MakerBundle; use Symfony\Bundle\MakerBundle\MakerBundle;
use Symfony\Bundle\SecurityBundle\SecurityBundle; use Symfony\Bundle\SecurityBundle\SecurityBundle;
@@ -34,6 +32,4 @@ return [
SymfonycastsSassBundle::class => ['all' => true], SymfonycastsSassBundle::class => ['all' => true],
StimulusBundle::class => ['all' => true], StimulusBundle::class => ['all' => true],
TurboBundle::class => ['all' => true], TurboBundle::class => ['all' => true],
DAMADoctrineTestBundle::class => ['test' => true],
StofDoctrineExtensionsBundle::class => ['all' => true],
]; ];

View File

@@ -1,5 +0,0 @@
when@test:
dama_doctrine_test:
enable_static_connection: true
enable_static_meta_data_cache: true
enable_static_query_cache: true

View File

@@ -2,22 +2,16 @@ doctrine:
dbal: dbal:
url: '%env(resolve:DATABASE_URL)%' url: '%env(resolve:DATABASE_URL)%'
# IMPORTANT: You MUST configure your server version,
# either here or in the DATABASE_URL env var (see .env file)
#server_version: '16'
profiling_collect_backtrace: '%kernel.debug%' profiling_collect_backtrace: '%kernel.debug%'
types: use_savepoints: true
# JSON types
jsonb: MartinGeorgiev\Doctrine\DBAL\Types\Jsonb
'jsonb[]': MartinGeorgiev\Doctrine\DBAL\Types\JsonbArray
tsrange: MartinGeorgiev\Doctrine\DBAL\Types\TsRange
mapping_types:
# JSON type mappings
jsonb: jsonb
'jsonb[]': 'jsonb[]'
_jsonb: 'jsonb[]'
tsrange: tsrange
orm: orm:
enable_native_lazy_objects: true auto_generate_proxy_classes: true
enable_lazy_ghost_objects: true
report_fields_where_declared: true
validate_xml_mapping: true validate_xml_mapping: true
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
identity_generation_preferences: identity_generation_preferences:
@@ -42,6 +36,8 @@ when@test:
when@prod: when@prod:
doctrine: doctrine:
orm: orm:
auto_generate_proxy_classes: false
proxy_dir: '%kernel.build_dir%/doctrine/orm/Proxies'
query_cache_driver: query_cache_driver:
type: pool type: pool
pool: doctrine.system_cache_pool pool: doctrine.system_cache_pool

View File

@@ -1,36 +1,31 @@
when@prod: when@prod:
sentry: sentry:
dsn: '%env(SENTRY_DSN)%' dsn: '%env(SENTRY_DSN)%'
options:
# Add request headers, cookies, IP address and the authenticated user # Add request headers, cookies, IP address and the authenticated user
# see https://docs.sentry.io/platforms/php/data-management/data-collected/ for more info # see https://docs.sentry.io/platforms/php/data-management/data-collected/ for more info
# send_default_pii: true # send_default_pii: true
options:
traces_sample_rate: 1.0
profiles_sample_rate: 1.0
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
# process_psr_3_messages: false # Disables the resolution of PSR-3 placeholders # Uncomment these lines to register a log message processor that resolves 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:
# Sentry\SentryBundle\Monolog\LogsHandler: # Monolog\Processor\PsrLogMessageProcessor:
# arguments: # tags: { name: monolog.processor, handler: sentry }
# - !php/const Monolog\Logger::INFO

View File

@@ -1,7 +0,0 @@
# Read the documentation: https://symfony.com/doc/current/bundles/StofDoctrineExtensionsBundle/index.html
# See the official DoctrineExtensions documentation for more details: https://github.com/doctrine-extensions/DoctrineExtensions/tree/main/doc
stof_doctrine_extensions:
default_locale: nl
orm:
default:
timestampable: true

4
config/packages/uid.yaml Normal file
View File

@@ -0,0 +1,4 @@
framework:
uid:
default_uuid_version: 7
time_based_uuid_version: 7

View File

@@ -2,6 +2,6 @@
declare(strict_types=1); declare(strict_types=1);
if (file_exists(dirname(__DIR__).'/var/cache/prod/Tvdt_KernelProdContainer.preload.php')) { if (file_exists(dirname(__DIR__).'/var/cache/prod/App_KernelProdContainer.preload.php')) {
require dirname(__DIR__).'/var/cache/prod/Tvdt_KernelProdContainer.preload.php'; require dirname(__DIR__).'/var/cache/prod/App_KernelProdContainer.preload.php';
} }

File diff suppressed because it is too large Load Diff

View File

@@ -1,84 +0,0 @@
# This file is part of the Symfony package.
#
# (c) Fabien Potencier <fabien@symfony.com>
#
# For the full copyright and license information, please view
# https://symfony.com/doc/current/contributing/code/license.html
_sf_composer() {
# Use newline as only separator to allow space in completion values
local IFS=$'\n'
local sf_cmd="${COMP_WORDS[0]}"
# for an alias, get the real script behind it
sf_cmd_type=$(type -t $sf_cmd)
if [[ $sf_cmd_type == "alias" ]]; then
sf_cmd=$(alias $sf_cmd | sed -E "s/alias $sf_cmd='(.*)'/\1/")
elif [[ $sf_cmd_type == "file" ]]; then
sf_cmd=$(type -p $sf_cmd)
fi
if [[ $sf_cmd_type != "function" && ! -x $sf_cmd ]]; then
return 1
fi
local cur prev words cword
_get_comp_words_by_ref -n := cur prev words cword
local completecmd=("$sf_cmd" "_complete" "--no-interaction" "-sbash" "-c$cword" "-S2.8.11")
for w in ${words[@]}; do
w=$(printf -- '%b' "$w")
# remove quotes from typed values
quote="${w:0:1}"
if [ "$quote" == \' ]; then
w="${w%\'}"
w="${w#\'}"
elif [ "$quote" == \" ]; then
w="${w%\"}"
w="${w#\"}"
fi
# empty values are ignored
if [ ! -z "$w" ]; then
completecmd+=("-i$w")
fi
done
local sfcomplete
if sfcomplete=$(${completecmd[@]} 2>&1); then
local quote suggestions
quote=${cur:0:1}
# Use single quotes by default if suggestions contains backslash (FQCN)
if [ "$quote" == '' ] && [[ "$sfcomplete" =~ \\ ]]; then
quote=\'
fi
if [ "$quote" == \' ]; then
# single quotes: no additional escaping (does not accept ' in values)
suggestions=$(for s in $sfcomplete; do printf $'%q%q%q\n' "$quote" "$s" "$quote"; done)
elif [ "$quote" == \" ]; then
# double quotes: double escaping for \ $ ` "
suggestions=$(for s in $sfcomplete; do
s=${s//\\/\\\\}
s=${s//\$/\\\$}
s=${s//\`/\\\`}
s=${s//\"/\\\"}
printf $'%q%q%q\n' "$quote" "$s" "$quote";
done)
else
# no quotes: double escaping
suggestions=$(for s in $sfcomplete; do printf $'%q\n' $(printf '%q' "$s"); done)
fi
COMPREPLY=($(IFS=$'\n' compgen -W "$suggestions" -- $(printf -- "%q" "$cur")))
__ltrim_colon_completions "$cur"
else
if [[ "$sfcomplete" != *"Command \"_complete\" is not defined."* ]]; then
>&2 echo
>&2 echo $sfcomplete
fi
return 1
fi
}
complete -F _sf_composer composer

View File

@@ -1,94 +0,0 @@
# This file is part of the Symfony package.
#
# (c) Fabien Potencier <fabien@symfony.com>
#
# For the full copyright and license information, please view
# https://symfony.com/doc/current/contributing/code/license.html
_sf_console() {
# Use the default completion for shell redirect operators.
for w in '>' '>>' '&>' '<'; do
if [[ $w = "${COMP_WORDS[COMP_CWORD-1]}" ]]; then
compopt -o filenames
COMPREPLY=($(compgen -f -- "${COMP_WORDS[COMP_CWORD]}"))
return 0
fi
done
# Use newline as only separator to allow space in completion values
local IFS=$'\n'
local sf_cmd="${COMP_WORDS[0]}"
# for an alias, get the real script behind it
sf_cmd_type=$(type -t $sf_cmd)
if [[ $sf_cmd_type == "alias" ]]; then
sf_cmd=$(alias $sf_cmd | sed -E "s/alias $sf_cmd='(.*)'/\1/")
elif [[ $sf_cmd_type == "file" ]]; then
sf_cmd=$(type -p $sf_cmd)
fi
if [[ $sf_cmd_type != "function" && ! -x $sf_cmd ]]; then
return 1
fi
local cur prev words cword
_get_comp_words_by_ref -n := cur prev words cword
local completecmd=("$sf_cmd" "_complete" "--no-interaction" "-sbash" "-c$cword" "-a1")
for w in ${words[@]}; do
w="${w//\\\\/\\}"
# remove quotes from typed values
quote="${w:0:1}"
if [ "$quote" == \' ]; then
w="${w%\'}"
w="${w#\'}"
elif [ "$quote" == \" ]; then
w="${w%\"}"
w="${w#\"}"
fi
# empty values are ignored
if [ ! -z "$w" ]; then
completecmd+=("-i$w")
fi
done
local sfcomplete
if sfcomplete=$(${completecmd[@]} 2>&1); then
local quote suggestions
quote=${cur:0:1}
# Use single quotes by default if suggestions contains backslash (FQCN)
if [ "$quote" == '' ] && [[ "$sfcomplete" =~ \\ ]]; then
quote=\'
fi
if [ "$quote" == \' ]; then
# single quotes: no additional escaping (does not accept ' in values)
suggestions=$(for s in $sfcomplete; do printf $'%q%q%q\n' "$quote" "$s" "$quote"; done)
elif [ "$quote" == \" ]; then
# double quotes: double escaping for \ $ ` "
suggestions=$(for s in $sfcomplete; do
s=${s//\\/\\\\}
s=${s//\$/\\\$}
s=${s//\`/\\\`}
s=${s//\"/\\\"}
printf $'%q%q%q\n' "$quote" "$s" "$quote";
done)
else
# no quotes: double escaping
suggestions=$(for s in $sfcomplete; do printf $'%q\n' $(printf '%q' "$s"); done)
fi
COMPREPLY=($(IFS=$'\n' compgen -W "$suggestions" -- $(printf -- "%q" "$cur")))
__ltrim_colon_completions "$cur"
else
if [[ "$sfcomplete" != *"Command \"_complete\" is not defined."* ]]; then
>&2 echo
>&2 echo $sfcomplete
fi
return 1
fi
}
complete -F _sf_console console

View File

@@ -7,6 +7,9 @@ namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration; use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20241229195702 extends AbstractMigration final class Version20241229195702 extends AbstractMigration
{ {
public function getDescription(): string public function getDescription(): string
@@ -16,6 +19,7 @@ final class Version20241229195702 extends AbstractMigration
public function up(Schema $schema): void public function up(Schema $schema): void
{ {
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE answer (id UUID NOT NULL, question_id UUID NOT NULL, text VARCHAR(255) NOT NULL, is_right_answer BOOLEAN NOT NULL, PRIMARY KEY(id))'); $this->addSql('CREATE TABLE answer (id UUID NOT NULL, question_id UUID NOT NULL, text VARCHAR(255) NOT NULL, is_right_answer BOOLEAN NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_DADD4A251E27F6BF ON answer (question_id)'); $this->addSql('CREATE INDEX IDX_DADD4A251E27F6BF ON answer (question_id)');
$this->addSql('COMMENT ON COLUMN answer.id IS \'(DC2Type:uuid)\''); $this->addSql('COMMENT ON COLUMN answer.id IS \'(DC2Type:uuid)\'');
@@ -63,6 +67,7 @@ final class Version20241229195702 extends AbstractMigration
public function down(Schema $schema): void public function down(Schema $schema): void
{ {
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE SCHEMA public'); $this->addSql('CREATE SCHEMA public');
$this->addSql('ALTER TABLE answer DROP CONSTRAINT FK_DADD4A251E27F6BF'); $this->addSql('ALTER TABLE answer DROP CONSTRAINT FK_DADD4A251E27F6BF');
$this->addSql('ALTER TABLE answer_candidate DROP CONSTRAINT FK_F54D5192AA334807'); $this->addSql('ALTER TABLE answer_candidate DROP CONSTRAINT FK_F54D5192AA334807');

View File

@@ -7,6 +7,9 @@ namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration; use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20241229201314 extends AbstractMigration final class Version20241229201314 extends AbstractMigration
{ {
public function getDescription(): string public function getDescription(): string
@@ -16,6 +19,7 @@ final class Version20241229201314 extends AbstractMigration
public function up(Schema $schema): void public function up(Schema $schema): void
{ {
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE season_user (season_id UUID NOT NULL, user_id UUID NOT NULL, PRIMARY KEY(season_id, user_id))'); $this->addSql('CREATE TABLE season_user (season_id UUID NOT NULL, user_id UUID NOT NULL, PRIMARY KEY(season_id, user_id))');
$this->addSql('CREATE INDEX IDX_BDA4AD74EC001D1 ON season_user (season_id)'); $this->addSql('CREATE INDEX IDX_BDA4AD74EC001D1 ON season_user (season_id)');
$this->addSql('CREATE INDEX IDX_BDA4AD7A76ED395 ON season_user (user_id)'); $this->addSql('CREATE INDEX IDX_BDA4AD7A76ED395 ON season_user (user_id)');
@@ -27,6 +31,7 @@ final class Version20241229201314 extends AbstractMigration
public function down(Schema $schema): void public function down(Schema $schema): void
{ {
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE SCHEMA public'); $this->addSql('CREATE SCHEMA public');
$this->addSql('ALTER TABLE season_user DROP CONSTRAINT FK_BDA4AD74EC001D1'); $this->addSql('ALTER TABLE season_user DROP CONSTRAINT FK_BDA4AD74EC001D1');
$this->addSql('ALTER TABLE season_user DROP CONSTRAINT FK_BDA4AD7A76ED395'); $this->addSql('ALTER TABLE season_user DROP CONSTRAINT FK_BDA4AD7A76ED395');

View File

@@ -7,6 +7,9 @@ namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration; use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20241229202103 extends AbstractMigration final class Version20241229202103 extends AbstractMigration
{ {
public function getDescription(): string public function getDescription(): string
@@ -16,6 +19,7 @@ final class Version20241229202103 extends AbstractMigration
public function up(Schema $schema): void public function up(Schema $schema): void
{ {
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE correction (id UUID NOT NULL, candidate_id UUID NOT NULL, quiz_id UUID NOT NULL, amount DOUBLE PRECISION NOT NULL, PRIMARY KEY(id))'); $this->addSql('CREATE TABLE correction (id UUID NOT NULL, candidate_id UUID NOT NULL, quiz_id UUID NOT NULL, amount DOUBLE PRECISION NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_A29DA1B891BD8781 ON correction (candidate_id)'); $this->addSql('CREATE INDEX IDX_A29DA1B891BD8781 ON correction (candidate_id)');
$this->addSql('CREATE INDEX IDX_A29DA1B8853CD175 ON correction (quiz_id)'); $this->addSql('CREATE INDEX IDX_A29DA1B8853CD175 ON correction (quiz_id)');
@@ -28,6 +32,7 @@ final class Version20241229202103 extends AbstractMigration
public function down(Schema $schema): void public function down(Schema $schema): void
{ {
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE SCHEMA public'); $this->addSql('CREATE SCHEMA public');
$this->addSql('ALTER TABLE correction DROP CONSTRAINT FK_A29DA1B891BD8781'); $this->addSql('ALTER TABLE correction DROP CONSTRAINT FK_A29DA1B891BD8781');
$this->addSql('ALTER TABLE correction DROP CONSTRAINT FK_A29DA1B8853CD175'); $this->addSql('ALTER TABLE correction DROP CONSTRAINT FK_A29DA1B8853CD175');

View File

@@ -7,6 +7,9 @@ namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration; use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20241229202155 extends AbstractMigration final class Version20241229202155 extends AbstractMigration
{ {
public function getDescription(): string public function getDescription(): string
@@ -16,11 +19,13 @@ final class Version20241229202155 extends AbstractMigration
public function up(Schema $schema): void public function up(Schema $schema): void
{ {
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE UNIQUE INDEX UNIQ_A29DA1B891BD8781853CD175 ON correction (candidate_id, quiz_id)'); $this->addSql('CREATE UNIQUE INDEX UNIQ_A29DA1B891BD8781853CD175 ON correction (candidate_id, quiz_id)');
} }
public function down(Schema $schema): void public function down(Schema $schema): void
{ {
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE SCHEMA public'); $this->addSql('CREATE SCHEMA public');
$this->addSql('DROP INDEX UNIQ_A29DA1B891BD8781853CD175'); $this->addSql('DROP INDEX UNIQ_A29DA1B891BD8781853CD175');
} }

View File

@@ -7,6 +7,9 @@ namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration; use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20241229204335 extends AbstractMigration final class Version20241229204335 extends AbstractMigration
{ {
public function getDescription(): string public function getDescription(): string
@@ -16,12 +19,14 @@ final class Version20241229204335 extends AbstractMigration
public function up(Schema $schema): void public function up(Schema $schema): void
{ {
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE given_answer ALTER answer_id DROP NOT NULL'); $this->addSql('ALTER TABLE given_answer ALTER answer_id DROP NOT NULL');
$this->addSql('ALTER TABLE given_answer ALTER created DROP NOT NULL'); $this->addSql('ALTER TABLE given_answer ALTER created DROP NOT NULL');
} }
public function down(Schema $schema): void public function down(Schema $schema): void
{ {
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE SCHEMA public'); $this->addSql('CREATE SCHEMA public');
$this->addSql('ALTER TABLE given_answer ALTER answer_id SET NOT NULL'); $this->addSql('ALTER TABLE given_answer ALTER answer_id SET NOT NULL');
$this->addSql('ALTER TABLE given_answer ALTER created SET NOT NULL'); $this->addSql('ALTER TABLE given_answer ALTER created SET NOT NULL');

View File

@@ -7,6 +7,9 @@ namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration; use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20250303221227 extends AbstractMigration final class Version20250303221227 extends AbstractMigration
{ {
public function getDescription(): string public function getDescription(): string
@@ -16,6 +19,7 @@ final class Version20250303221227 extends AbstractMigration
public function up(Schema $schema): void public function up(Schema $schema): void
{ {
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE given_answer ALTER created SET NOT NULL'); $this->addSql('ALTER TABLE given_answer ALTER created SET NOT NULL');
$this->addSql('ALTER TABLE season ADD active_quiz_id UUID DEFAULT NULL'); $this->addSql('ALTER TABLE season ADD active_quiz_id UUID DEFAULT NULL');
$this->addSql('COMMENT ON COLUMN season.active_quiz_id IS \'(DC2Type:uuid)\''); $this->addSql('COMMENT ON COLUMN season.active_quiz_id IS \'(DC2Type:uuid)\'');
@@ -25,6 +29,7 @@ final class Version20250303221227 extends AbstractMigration
public function down(Schema $schema): void public function down(Schema $schema): void
{ {
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE SCHEMA public'); $this->addSql('CREATE SCHEMA public');
$this->addSql('ALTER TABLE season DROP CONSTRAINT FK_F0E45BA96706D6B'); $this->addSql('ALTER TABLE season DROP CONSTRAINT FK_F0E45BA96706D6B');
$this->addSql('DROP INDEX IDX_F0E45BA96706D6B'); $this->addSql('DROP INDEX IDX_F0E45BA96706D6B');

View File

@@ -7,6 +7,9 @@ namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration; use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20250311213417 extends AbstractMigration final class Version20250311213417 extends AbstractMigration
{ {
public function getDescription(): string public function getDescription(): string
@@ -16,6 +19,7 @@ final class Version20250311213417 extends AbstractMigration
public function up(Schema $schema): void public function up(Schema $schema): void
{ {
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE answer ALTER id TYPE UUID'); $this->addSql('ALTER TABLE answer ALTER id TYPE UUID');
$this->addSql('ALTER TABLE answer ALTER question_id TYPE UUID'); $this->addSql('ALTER TABLE answer ALTER question_id TYPE UUID');
$this->addSql('COMMENT ON COLUMN answer.id IS \'\''); $this->addSql('COMMENT ON COLUMN answer.id IS \'\'');
@@ -65,6 +69,7 @@ final class Version20250311213417 extends AbstractMigration
public function down(Schema $schema): void public function down(Schema $schema): void
{ {
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE candidate ALTER id TYPE UUID'); $this->addSql('ALTER TABLE candidate ALTER id TYPE UUID');
$this->addSql('ALTER TABLE candidate ALTER season_id TYPE UUID'); $this->addSql('ALTER TABLE candidate ALTER season_id TYPE UUID');
$this->addSql('COMMENT ON COLUMN candidate.id IS \'(DC2Type:uuid)\''); $this->addSql('COMMENT ON COLUMN candidate.id IS \'(DC2Type:uuid)\'');

View File

@@ -7,6 +7,9 @@ namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration; use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20250402185128 extends AbstractMigration final class Version20250402185128 extends AbstractMigration
{ {
public function getDescription(): string public function getDescription(): string
@@ -16,11 +19,13 @@ final class Version20250402185128 extends AbstractMigration
public function up(Schema $schema): void public function up(Schema $schema): void
{ {
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE elimination (id UUID NOT NULL, data JSON NOT NULL, PRIMARY KEY(id))'); $this->addSql('CREATE TABLE elimination (id UUID NOT NULL, data JSON NOT NULL, PRIMARY KEY(id))');
} }
public function down(Schema $schema): void public function down(Schema $schema): void
{ {
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('DROP TABLE elimination'); $this->addSql('DROP TABLE elimination');
} }
} }

View File

@@ -7,6 +7,9 @@ namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration; use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20250427174822 extends AbstractMigration final class Version20250427174822 extends AbstractMigration
{ {
public function getDescription(): string public function getDescription(): string
@@ -16,6 +19,7 @@ final class Version20250427174822 extends AbstractMigration
public function up(Schema $schema): void public function up(Schema $schema): void
{ {
// this up() migration is auto-generated, please modify it to your needs
$this->addSql(<<<'SQL' $this->addSql(<<<'SQL'
ALTER TABLE answer ADD ordering SMALLINT DEFAULT 0 NOT NULL ALTER TABLE answer ADD ordering SMALLINT DEFAULT 0 NOT NULL
SQL); SQL);
@@ -26,6 +30,7 @@ final class Version20250427174822 extends AbstractMigration
public function down(Schema $schema): void public function down(Schema $schema): void
{ {
// this down() migration is auto-generated, please modify it to your needs
$this->addSql(<<<'SQL' $this->addSql(<<<'SQL'
ALTER TABLE answer DROP ordering ALTER TABLE answer DROP ordering
SQL); SQL);

View File

@@ -7,6 +7,9 @@ namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration; use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20250504101440 extends AbstractMigration final class Version20250504101440 extends AbstractMigration
{ {
public function getDescription(): string public function getDescription(): string
@@ -16,6 +19,7 @@ final class Version20250504101440 extends AbstractMigration
public function up(Schema $schema): void public function up(Schema $schema): void
{ {
// this up() migration is auto-generated, please modify it to your needs
$this->addSql(<<<'SQL' $this->addSql(<<<'SQL'
CREATE UNIQUE INDEX UNIQ_C8B28E445E237E064EC001D1 ON candidate (name, season_id) CREATE UNIQUE INDEX UNIQ_C8B28E445E237E064EC001D1 ON candidate (name, season_id)
SQL); SQL);
@@ -26,6 +30,7 @@ final class Version20250504101440 extends AbstractMigration
public function down(Schema $schema): void public function down(Schema $schema): void
{ {
// this down() migration is auto-generated, please modify it to your needs
$this->addSql(<<<'SQL' $this->addSql(<<<'SQL'
DROP INDEX UNIQ_A412FA925E237E064EC001D1 DROP INDEX UNIQ_A412FA925E237E064EC001D1
SQL); SQL);

View File

@@ -7,6 +7,9 @@ namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration; use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20250606195952 extends AbstractMigration final class Version20250606195952 extends AbstractMigration
{ {
public function getDescription(): string public function getDescription(): string

View File

@@ -7,6 +7,9 @@ namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration; use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20250607154730 extends AbstractMigration final class Version20250607154730 extends AbstractMigration
{ {
public function getDescription(): string public function getDescription(): string
@@ -16,6 +19,7 @@ final class Version20250607154730 extends AbstractMigration
public function up(Schema $schema): void public function up(Schema $schema): void
{ {
// this up() migration is auto-generated, please modify it to your needs
$this->addSql(<<<'SQL' $this->addSql(<<<'SQL'
ALTER TABLE season DROP CONSTRAINT FK_F0E45BA96706D6B ALTER TABLE season DROP CONSTRAINT FK_F0E45BA96706D6B
SQL); SQL);
@@ -26,6 +30,7 @@ final class Version20250607154730 extends AbstractMigration
public function down(Schema $schema): void public function down(Schema $schema): void
{ {
// this down() migration is auto-generated, please modify it to your needs
$this->addSql(<<<'SQL' $this->addSql(<<<'SQL'
ALTER TABLE season DROP CONSTRAINT fk_f0e45ba96706d6b ALTER TABLE season DROP CONSTRAINT fk_f0e45ba96706d6b
SQL); SQL);

View File

@@ -7,6 +7,9 @@ namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration; use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20250607184525 extends AbstractMigration final class Version20250607184525 extends AbstractMigration
{ {
public function getDescription(): string public function getDescription(): string
@@ -16,6 +19,7 @@ final class Version20250607184525 extends AbstractMigration
public function up(Schema $schema): void public function up(Schema $schema): void
{ {
// this up() migration is auto-generated, please modify it to your needs
$this->addSql(<<<'SQL' $this->addSql(<<<'SQL'
ALTER TABLE elimination DROP CONSTRAINT FK_5947284F853CD175 ALTER TABLE elimination DROP CONSTRAINT FK_5947284F853CD175
SQL); SQL);
@@ -32,6 +36,7 @@ final class Version20250607184525 extends AbstractMigration
public function down(Schema $schema): void public function down(Schema $schema): void
{ {
// this down() migration is auto-generated, please modify it to your needs
$this->addSql(<<<'SQL' $this->addSql(<<<'SQL'
ALTER TABLE given_answer DROP CONSTRAINT fk_9ac61a30853cd175 ALTER TABLE given_answer DROP CONSTRAINT fk_9ac61a30853cd175
SQL); SQL);

View File

@@ -1,26 +0,0 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20251007194241 extends AbstractMigration
{
public function getDescription(): string
{
return 'Change elimination data type to jsonb';
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE elimination ALTER data TYPE JSONB');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE elimination ALTER data TYPE JSON');
}
}

View File

@@ -27,12 +27,8 @@
<include> <include>
<directory>src</directory> <directory>src</directory>
</include> </include>
<exclude>
<directory>src/DataFixtures</directory>
</exclude>
</source> </source>
<extensions> <extensions>
<bootstrap class="DAMA\DoctrineTestBundle\PHPUnit\PHPUnitExtension" />
</extensions> </extensions>
</phpunit> </phpunit>

View File

@@ -3,8 +3,6 @@
declare(strict_types=1); declare(strict_types=1);
use Rector\Config\RectorConfig; use Rector\Config\RectorConfig;
use Rector\Symfony\Bridge\Symfony\Routing\SymfonyRoutesProvider;
use Rector\Symfony\Contract\Bridge\Symfony\Routing\SymfonyRoutesProviderInterface;
return RectorConfig::configure() return RectorConfig::configure()
->withPaths([ ->withPaths([
@@ -13,10 +11,7 @@ return RectorConfig::configure()
__DIR__.'/src', __DIR__.'/src',
__DIR__.'/tests', __DIR__.'/tests',
]) ])
->withSkip([__DIR__.'/config/reference.php']) ->withSymfonyContainerXml('var/cache/dev/App_KernelDevDebugContainer.xml')
->withSymfonyContainerXml(__DIR__.'/var/cache/dev/Tvdt_KernelDevDebugContainer.xml')
->withSymfonyContainerPhp(__DIR__.'/tests/symfony-container.php')
->registerService(SymfonyRoutesProvider::class, SymfonyRoutesProviderInterface::class)
->withParallel() ->withParallel()
->withPhpSets() ->withPhpSets()
->withPreparedSets( ->withPreparedSets(
@@ -27,6 +22,7 @@ return RectorConfig::configure()
privatization: true, privatization: true,
instanceOf: true, instanceOf: true,
earlyReturn: true, earlyReturn: true,
strictBooleans: true,
rectorPreset: true, rectorPreset: true,
phpunitCodeQuality: true, phpunitCodeQuality: true,
doctrineCodeQuality: true, doctrineCodeQuality: true,

View File

@@ -0,0 +1,41 @@
<?php
declare(strict_types=1);
namespace Tvdt\Command;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Tvdt\Entity\SeasonSettings;
use Tvdt\Repository\SeasonRepository;
#[AsCommand(
name: 'tvdt:add-settings',
description: 'Add a short description for your command',
)]
readonly class AddSettingsCommand
{
public function __construct(private SeasonRepository $seasonRepository, private EntityManagerInterface $entityManager) {}
public function __invoke(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
foreach ($this->seasonRepository->findAll() as $season) {
if (null !== $season->getSettings()) {
continue;
}
$io->text('Adding settings to season : '.$season->getSeasonCode());
$season->setSettings(new SeasonSettings());
}
$this->entityManager->flush();
return Command::SUCCESS;
}
}

View File

@@ -8,8 +8,9 @@ use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Console\Attribute\Argument; use Symfony\Component\Console\Attribute\Argument;
use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\Console\Style\SymfonyStyle;
use Tvdt\Entity\Season;
use Tvdt\Repository\SeasonRepository; use Tvdt\Repository\SeasonRepository;
use Tvdt\Repository\UserRepository; use Tvdt\Repository\UserRepository;
@@ -17,7 +18,7 @@ use Tvdt\Repository\UserRepository;
name: 'tvdt:claim-season', name: 'tvdt:claim-season',
description: 'Give a user owner rights on a season', description: 'Give a user owner rights on a season',
)] )]
final readonly class ClaimSeasonCommand readonly class ClaimSeasonCommand
{ {
public function __construct(private UserRepository $userRepository, private SeasonRepository $seasonRepository, private EntityManagerInterface $entityManager) {} public function __construct(private UserRepository $userRepository, private SeasonRepository $seasonRepository, private EntityManagerInterface $entityManager) {}
@@ -26,11 +27,14 @@ final readonly class ClaimSeasonCommand
string $seasonCode, string $seasonCode,
#[Argument] #[Argument]
string $email, string $email,
SymfonyStyle $io, InputInterface $input,
OutputInterface $output,
): int { ): int {
$io = new SymfonyStyle($input, $output);
try { try {
$season = $this->seasonRepository->findOneBySeasonCode($seasonCode); $season = $this->seasonRepository->findOneBy(['seasonCode' => $seasonCode]);
if (!$season instanceof Season) { if (null === $season) {
throw new \InvalidArgumentException('Season not found'); throw new \InvalidArgumentException('Season not found');
} }

View File

@@ -7,6 +7,8 @@ namespace Tvdt\Command;
use Symfony\Component\Console\Attribute\Argument; use Symfony\Component\Console\Attribute\Argument;
use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\Console\Style\SymfonyStyle;
use Tvdt\Repository\UserRepository; use Tvdt\Repository\UserRepository;
@@ -14,15 +16,17 @@ use Tvdt\Repository\UserRepository;
name: 'tvdt:make-admin', name: 'tvdt:make-admin',
description: 'Give a user the role admin', description: 'Give a user the role admin',
)] )]
final readonly class MakeAdminCommand readonly class MakeAdminCommand
{ {
public function __construct(private UserRepository $userRepository) {} public function __construct(private UserRepository $userRepository) {}
public function __invoke( public function __invoke(
#[Argument] #[Argument]
string $email, string $email,
SymfonyStyle $io, InputInterface $input,
OutputInterface $output,
): int { ): int {
$io = new SymfonyStyle($input, $output);
try { try {
$this->userRepository->makeAdmin($email); $this->userRepository->makeAdmin($email);
} catch (\InvalidArgumentException) { } catch (\InvalidArgumentException) {

View File

@@ -26,7 +26,6 @@ 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')]
@@ -62,16 +61,16 @@ final class BackofficeController extends AbstractController
$em->persist($season); $em->persist($season);
$em->flush(); $em->flush();
return $this->redirectToRoute('tvdt_backoffice_season', ['seasonCode' => $season->seasonCode]); return $this->redirectToRoute('tvdt_backoffice_season', ['seasonCode' => $season->getSeasonCode()]);
} }
return $this->render('backoffice/season_add.html.twig', ['form' => $form]); return $this->render('backoffice/season_add.html.twig', ['form' => $form]);
} }
#[Route('/backoffice/template', name: 'tvdt_backoffice_template', priority: 10)] #[Route('/backoffice/template', name: 'tvdt_backoffice_template', priority: 10)]
public function getTemplate(): StreamedResponse public function getTemplate(QuizSpreadsheetService $excel): Response
{ {
$response = new StreamedResponse($this->excel->generateTemplate()); $response = new StreamedResponse($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,7 +5,6 @@ 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;
@@ -18,18 +17,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): RedirectResponse public function index(Season $season, Quiz $quiz, EliminationFactory $eliminationFactory): Response
{ {
$elimination = $this->eliminationFactory->createEliminationFromQuiz($quiz); $elimination = $eliminationFactory->createEliminationFromQuiz($quiz);
return $this->redirectToRoute('tvdt_prepare_elimination_view', ['elimination' => $elimination->id]); return $this->redirectToRoute('tvdt_prepare_elimination_view', ['elimination' => $elimination->getId()]);
} }
#[Route( #[Route(
@@ -44,7 +41,7 @@ final class PrepareEliminationController extends AbstractController
$em->flush(); $em->flush();
if ($request->request->getBoolean('start')) { if ($request->request->getBoolean('start')) {
return $this->redirectToRoute('tvdt_elimination', ['elimination' => $elimination->id]); return $this->redirectToRoute('tvdt_elimination', ['elimination' => $elimination->getId()]);
} }
$this->addFlash('success', 'Elimination updated'); $this->addFlash('success', 'Elimination updated');

View File

@@ -19,6 +19,7 @@ use Tvdt\Entity\Candidate;
use Tvdt\Entity\Quiz; use Tvdt\Entity\Quiz;
use Tvdt\Entity\Season; use Tvdt\Entity\Season;
use Tvdt\Exception\ErrorClearingQuizException; use Tvdt\Exception\ErrorClearingQuizException;
use Tvdt\Repository\CandidateRepository;
use Tvdt\Repository\QuizCandidateRepository; use Tvdt\Repository\QuizCandidateRepository;
use Tvdt\Repository\QuizRepository; use Tvdt\Repository\QuizRepository;
use Tvdt\Security\Voter\SeasonVoter; use Tvdt\Security\Voter\SeasonVoter;
@@ -28,9 +29,8 @@ use Tvdt\Security\Voter\SeasonVoter;
class QuizController extends AbstractController class QuizController extends AbstractController
{ {
public function __construct( public function __construct(
private readonly QuizRepository $quizRepository, private readonly CandidateRepository $candidateRepository,
private readonly TranslatorInterface $translator, private readonly TranslatorInterface $translator,
private readonly QuizCandidateRepository $quizCandidateRepository,
) {} ) {}
#[IsGranted(SeasonVoter::EDIT, subject: 'season')] #[IsGranted(SeasonVoter::EDIT, subject: 'season')]
@@ -44,7 +44,7 @@ class QuizController extends AbstractController
return $this->render('backoffice/quiz.html.twig', [ return $this->render('backoffice/quiz.html.twig', [
'season' => $season, 'season' => $season,
'quiz' => $quiz, 'quiz' => $quiz,
'result' => $this->quizRepository->getScores($quiz), 'result' => $this->candidateRepository->getScores($quiz),
]); ]);
} }
@@ -56,14 +56,14 @@ class QuizController extends AbstractController
)] )]
public function enableQuiz(Season $season, ?Quiz $quiz, EntityManagerInterface $em): RedirectResponse public function enableQuiz(Season $season, ?Quiz $quiz, EntityManagerInterface $em): RedirectResponse
{ {
$season->activeQuiz = $quiz; $season->setActiveQuiz($quiz);
$em->flush(); $em->flush();
if ($quiz instanceof Quiz) { if ($quiz instanceof Quiz) {
return $this->redirectToRoute('tvdt_backoffice_quiz', ['seasonCode' => $season->seasonCode, 'quiz' => $quiz->id]); return $this->redirectToRoute('tvdt_backoffice_quiz', ['seasonCode' => $season->getSeasonCode(), 'quiz' => $quiz->getId()]);
} }
return $this->redirectToRoute('tvdt_backoffice_season', ['seasonCode' => $season->seasonCode]); return $this->redirectToRoute('tvdt_backoffice_season', ['seasonCode' => $season->getSeasonCode()]);
} }
#[IsGranted(SeasonVoter::EDIT, subject: 'quiz')] #[IsGranted(SeasonVoter::EDIT, subject: 'quiz')]
@@ -72,16 +72,16 @@ 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): RedirectResponse public function clearQuiz(Quiz $quiz, QuizRepository $quizRepository): RedirectResponse
{ {
try { try {
$this->quizRepository->clearQuiz($quiz); $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'));
} }
return $this->redirectToRoute('tvdt_backoffice_quiz', ['seasonCode' => $quiz->season->seasonCode, 'quiz' => $quiz->id]); return $this->redirectToRoute('tvdt_backoffice_quiz', ['seasonCode' => $quiz->getSeason()->getSeasonCode(), 'quiz' => $quiz->getId()]);
} }
#[IsGranted(SeasonVoter::DELETE, subject: 'quiz')] #[IsGranted(SeasonVoter::DELETE, subject: 'quiz')]
@@ -90,13 +90,13 @@ 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): RedirectResponse public function deleteQuiz(Quiz $quiz, QuizRepository $quizRepository): RedirectResponse
{ {
$this->quizRepository->deleteQuiz($quiz); $quizRepository->deleteQuiz($quiz);
$this->addFlash('success', $this->translator->trans('Quiz deleted')); $this->addFlash('success', $this->translator->trans('Quiz deleted'));
return $this->redirectToRoute('tvdt_backoffice_season', ['seasonCode' => $quiz->season->seasonCode]); return $this->redirectToRoute('tvdt_backoffice_season', ['seasonCode' => $quiz->getSeason()->getSeasonCode()]);
} }
#[IsGranted(SeasonVoter::EDIT, subject: 'quiz')] #[IsGranted(SeasonVoter::EDIT, subject: 'quiz')]
@@ -105,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, Request $request): RedirectResponse public function modifyCorrection(Quiz $quiz, Candidate $candidate, QuizCandidateRepository $quizCandidateRepository, Request $request): RedirectResponse
{ {
if (!$request->isMethod('POST')) { if (!$request->isMethod('POST')) {
throw new MethodNotAllowedHttpException(['POST']); throw new MethodNotAllowedHttpException(['POST']);
@@ -113,8 +113,8 @@ class QuizController extends AbstractController
$corrections = (float) $request->request->get('corrections'); $corrections = (float) $request->request->get('corrections');
$this->quizCandidateRepository->setCorrectionsForCandidate($quiz, $candidate, $corrections); $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->getSeason()->getSeasonCode(), 'quiz' => $quiz->getId()]);
} }
} }

View File

@@ -30,7 +30,6 @@ 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')]
@@ -41,7 +40,7 @@ class SeasonController extends AbstractController
)] )]
public function index(Season $season, Request $request): Response public function index(Season $season, Request $request): Response
{ {
$form = $this->createForm(SettingsForm::class, $season->settings); $form = $this->createForm(SettingsForm::class, $season->getSettings());
$form->handleRequest($request); $form->handleRequest($request);
@@ -75,7 +74,7 @@ class SeasonController extends AbstractController
$this->em->flush(); $this->em->flush();
return $this->redirectToRoute('tvdt_backoffice_season', ['seasonCode' => $season->seasonCode]); return $this->redirectToRoute('tvdt_backoffice_season', ['seasonCode' => $season->getSeasonCode()]);
} }
return $this->render('backoffice/season_add_candidates.html.twig', ['form' => $form]); return $this->render('backoffice/season_add_candidates.html.twig', ['form' => $form]);
@@ -88,7 +87,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): Response public function addQuiz(Request $request, Season $season, QuizSpreadsheetService $quizSpreadsheet): Response
{ {
$quiz = new Quiz(); $quiz = new Quiz();
$form = $this->createForm(UploadQuizFormType::class, $quiz); $form = $this->createForm(UploadQuizFormType::class, $quiz);
@@ -99,15 +98,15 @@ class SeasonController extends AbstractController
/* @var UploadedFile $sheet */ /* @var UploadedFile $sheet */
$sheet = $form->get('sheet')->getData(); $sheet = $form->get('sheet')->getData();
$this->quizSpreadsheet->xlsxToQuiz($quiz, $sheet); $quizSpreadsheet->xlsxToQuiz($quiz, $sheet);
$quiz->season = $season; $quiz->setSeason($season);
$this->em->persist($quiz); $this->em->persist($quiz);
$this->em->flush(); $this->em->flush();
$this->addFlash(FlashType::Success, $this->translator->trans('Quiz Added!')); $this->addFlash(FlashType::Success, $this->translator->trans('Quiz Added!'));
return $this->redirectToRoute('tvdt_backoffice_season', ['seasonCode' => $season->seasonCode]); return $this->redirectToRoute('tvdt_backoffice_season', ['seasonCode' => $season->getSeasonCode()]);
} }
return $this->render('/backoffice/quiz_add.html.twig', ['form' => $form, 'season' => $season]); return $this->render('/backoffice/quiz_add.html.twig', ['form' => $form, 'season' => $season]);

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, private readonly CandidateRepository $candidateRepository) {} public function __construct(private readonly TranslatorInterface $translator) {}
#[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])]
@@ -39,7 +39,7 @@ final class EliminationController extends AbstractController
if ($form->isSubmitted() && $form->isValid()) { if ($form->isSubmitted() && $form->isValid()) {
$name = $form->get('name')->getData(); $name = $form->get('name')->getData();
return $this->redirectToRoute('tvdt_elimination_candidate', ['elimination' => $elimination->id, 'candidateHash' => Base64::base64UrlEncode($name)]); return $this->redirectToRoute('tvdt_elimination_candidate', ['elimination' => $elimination->getId(), 'candidateHash' => Base64::base64UrlEncode($name)]);
} }
return $this->render('quiz/elimination/index.html.twig', [ return $this->render('quiz/elimination/index.html.twig', [
@@ -50,23 +50,23 @@ 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): Response public function candidateScreen(Elimination $elimination, string $candidateHash, CandidateRepository $candidateRepository): Response
{ {
$candidate = $this->candidateRepository->getCandidateByHash($elimination->quiz->season, $candidateHash); $candidate = $candidateRepository->getCandidateByHash($elimination->getQuiz()->getSeason(), $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),
); );
return $this->redirectToRoute('tvdt_elimination', ['elimination' => $elimination->id]); return $this->redirectToRoute('tvdt_elimination', ['elimination' => $elimination->getId()]);
} }
$screenColour = $elimination->getScreenColour($candidate->name); $screenColour = $elimination->getScreenColour($candidate->getName());
if (null === $screenColour) { if (null === $screenColour) {
$this->addFlash(FlashType::Warning, $this->translator->trans('Cound not find candidate with name %name% in elimination.', ['%name%' => $candidate->name])); $this->addFlash(FlashType::Warning, $this->translator->trans('Cound not find candidate with name %name% in elimination.', ['%name%' => $candidate->getName()]));
return $this->redirectToRoute('tvdt_elimination', ['elimination' => $elimination->id]); return $this->redirectToRoute('tvdt_elimination', ['elimination' => $elimination->getId()]);
} }
return $this->render('quiz/elimination/candidate.html.twig', [ return $this->render('quiz/elimination/candidate.html.twig', [

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(): Response public function login(AuthenticationUtils $authenticationUtils, TranslatorInterface $translator): Response
{ {
// get the login error if there is one // get the login error if there is one
$error = $this->authenticationUtils->getLastAuthenticationError(); $error = $authenticationUtils->getLastAuthenticationError();
// last username entered by the user // last username entered by the user
$lastUsername = $this->authenticationUtils->getLastUsername(); $lastUsername = $authenticationUtils->getLastUsername();
if ($error instanceof AuthenticationException) { if ($error instanceof AuthenticationException) {
$this->addFlash(FlashType::Danger, $this->translator->trans($error->getMessageKey(), $error->getMessageData(), 'security')); $this->addFlash(FlashType::Danger, $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

@@ -4,7 +4,6 @@ declare(strict_types=1);
namespace Tvdt\Controller; namespace Tvdt\Controller;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Attribute\AsController; use Symfony\Component\HttpKernel\Attribute\AsController;
@@ -23,6 +22,7 @@ use Tvdt\Form\SelectSeasonType;
use Tvdt\Helpers\Base64; use Tvdt\Helpers\Base64;
use Tvdt\Repository\AnswerRepository; use Tvdt\Repository\AnswerRepository;
use Tvdt\Repository\CandidateRepository; use Tvdt\Repository\CandidateRepository;
use Tvdt\Repository\GivenAnswerRepository;
use Tvdt\Repository\QuestionRepository; use Tvdt\Repository\QuestionRepository;
use Tvdt\Repository\QuizCandidateRepository; use Tvdt\Repository\QuizCandidateRepository;
use Tvdt\Repository\SeasonRepository; use Tvdt\Repository\SeasonRepository;
@@ -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, private readonly SeasonRepository $seasonRepository, private readonly CandidateRepository $candidateRepository, private readonly QuestionRepository $questionRepository, private readonly AnswerRepository $answerRepository, private readonly QuizCandidateRepository $quizCandidateRepository) {} public function __construct(private readonly TranslatorInterface $translator) {}
#[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): Response public function selectSeason(Request $request, SeasonRepository $seasonRepository): 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 ([] === $this->seasonRepository->findBy(['seasonCode' => $seasonCode])) { if ([] === $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');
@@ -65,7 +65,7 @@ final class QuizController extends AbstractController
if ($form->isSubmitted() && $form->isValid()) { if ($form->isSubmitted() && $form->isValid()) {
$name = $form->get('name')->getData(); $name = $form->get('name')->getData();
return $this->redirectToRoute('tvdt_quiz_quiz_page', ['seasonCode' => $season->seasonCode, 'nameHash' => Base64::base64UrlEncode($name)]); return $this->redirectToRoute('tvdt_quiz_quiz_page', ['seasonCode' => $season->getSeasonCode(), 'nameHash' => Base64::base64UrlEncode($name)]);
} }
return $this->render('quiz/enter_name.twig', ['season' => $season, 'form' => $form]); return $this->render('quiz/enter_name.twig', ['season' => $season, 'form' => $form]);
@@ -80,52 +80,51 @@ final class QuizController extends AbstractController
Season $season, Season $season,
string $nameHash, string $nameHash,
Request $request, Request $request,
CandidateRepository $candidateRepository,
QuestionRepository $questionRepository,
AnswerRepository $answerRepository,
GivenAnswerRepository $givenAnswerRepository,
QuizCandidateRepository $quizCandidateRepository,
): Response { ): Response {
$candidate = $this->candidateRepository->getCandidateByHash($season, $nameHash); $candidate = $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'));
return $this->redirectToRoute('tvdt_quiz_enter_name', ['seasonCode' => $season->seasonCode]); return $this->redirectToRoute('tvdt_quiz_enter_name', ['seasonCode' => $season->getSeasonCode()]);
} }
$quiz = $season->activeQuiz; $quiz = $season->getActiveQuiz();
if (!$quiz instanceof Quiz) { if (!$quiz instanceof Quiz) {
$this->addFlash(FlashType::Warning, $this->translator->trans('There is no active quiz')); $this->addFlash(FlashType::Warning, $this->translator->trans('There is no active quiz'));
return $this->redirectToRoute('tvdt_quiz_enter_name', ['seasonCode' => $season->seasonCode]); return $this->redirectToRoute('tvdt_quiz_enter_name', ['seasonCode' => $season->getSeasonCode()]);
} }
if ('POST' === $request->getMethod()) { if ('POST' === $request->getMethod()) {
// 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');
} }
$givenAnswer = new GivenAnswer($candidate, $answer->question->quiz, $answer); $givenAnswer = new GivenAnswer($candidate, $answer->getQuestion()->getQuiz(), $answer);
$this->entityManager->persist($givenAnswer); $givenAnswerRepository->save($givenAnswer);
$this->entityManager->flush();
// end of extarcting saving answer logic return $this->redirectToRoute('tvdt_quiz_quiz_page', ['seasonCode' => $season->getSeasonCode(), 'nameHash' => $nameHash]);
return $this->redirectToRoute('tvdt_quiz_quiz_page', ['seasonCode' => $season->seasonCode, 'nameHash' => $nameHash]);
} }
// 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
if (!$question instanceof Question) { if (!$question instanceof Question) {
$this->addFlash(FlashType::Success, $this->translator->trans('Quiz completed')); $this->addFlash(FlashType::Success, $this->translator->trans('Quiz completed'));
return $this->redirectToRoute('tvdt_quiz_enter_name', ['seasonCode' => $season->seasonCode]); return $this->redirectToRoute('tvdt_quiz_enter_name', ['seasonCode' => $season->getSeasonCode()]);
} }
$this->quizCandidateRepository->createIfNotExist($quiz, $candidate); $quizCandidateRepository->createIfNotExist($quiz, $candidate);
// 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,7 +9,6 @@ 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;
@@ -24,12 +23,15 @@ 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, private readonly UserPasswordHasherInterface $userPasswordHasher, private readonly Security $security, private readonly LoggerInterface $logger, private readonly UserRepository $userRepository) {} public function __construct(private readonly EmailVerifier $emailVerifier, private readonly TranslatorInterface $translator) {}
#[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);
@@ -39,7 +41,7 @@ final class RegistrationController extends AbstractController
/** @var string $plainPassword */ /** @var string $plainPassword */
$plainPassword = $form->get('plainPassword')->getData(); $plainPassword = $form->get('plainPassword')->getData();
$user->password = $this->userPasswordHasher->hashPassword($user, $plainPassword); $user->setPassword($userPasswordHasher->hashPassword($user, $plainPassword));
$entityManager->persist($user); $entityManager->persist($user);
$entityManager->flush(); $entityManager->flush();
@@ -48,15 +50,15 @@ final class RegistrationController extends AbstractController
// generate a signed url and email it to the user // generate a signed url and email it to the user
$this->emailVerifier->sendEmailConfirmation('tvdt_verify_email', $user, $this->emailVerifier->sendEmailConfirmation('tvdt_verify_email', $user,
new TemplatedEmail() new TemplatedEmail()
->to($user->email) ->to((string) $user->getEmail())
->subject($this->translator->trans('Please Confirm your Email')) ->subject($this->translator->trans('Please Confirm your Email'))
->htmlTemplate('backoffice/registration/confirmation_email.html.twig'), ->htmlTemplate('backoffice/registration/confirmation_email.html.twig'),
); );
} catch (TransportExceptionInterface $e) { } catch (TransportExceptionInterface $e) {
$this->logger->error($e->getMessage()); $logger->error($e->getMessage());
} }
$response = $this->security->login($user, 'form_login', 'main'); $response = $security->login($user, 'form_login', 'main');
\assert($response instanceof Response); \assert($response instanceof Response);
return $response; return $response;
@@ -68,7 +70,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): RedirectResponse public function verifyUserEmail(Request $request, TranslatorInterface $translator, UserRepository $userRepository): Response
{ {
$id = $request->query->get('id'); $id = $request->query->get('id');
@@ -76,7 +78,7 @@ final class RegistrationController extends AbstractController
return $this->redirectToRoute('tvdt_register'); return $this->redirectToRoute('tvdt_register');
} }
$user = $this->userRepository->find($id); $user = $userRepository->find($id);
if (null === $user) { if (null === $user) {
return $this->redirectToRoute('tvdt_register'); return $this->redirectToRoute('tvdt_register');
@@ -86,7 +88,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', $this->translator->trans($verifyEmailException->getReason(), [], 'VerifyEmailBundle')); $this->addFlash('verify_email_error', $translator->trans($verifyEmailException->getReason(), [], 'VerifyEmailBundle'));
return $this->redirectToRoute('tvdt_register'); return $this->redirectToRoute('tvdt_register');
} }

View File

@@ -5,7 +5,6 @@ declare(strict_types=1);
namespace Tvdt\DataFixtures; namespace Tvdt\DataFixtures;
use Doctrine\Bundle\FixturesBundle\Fixture; use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Bundle\FixturesBundle\FixtureGroupInterface;
use Doctrine\Persistence\ObjectManager; use Doctrine\Persistence\ObjectManager;
use Tvdt\Entity\Answer; use Tvdt\Entity\Answer;
use Tvdt\Entity\Candidate; use Tvdt\Entity\Candidate;
@@ -13,23 +12,15 @@ use Tvdt\Entity\Question;
use Tvdt\Entity\Quiz; use Tvdt\Entity\Quiz;
use Tvdt\Entity\Season; use Tvdt\Entity\Season;
final class KrtekFixtures extends Fixture implements FixtureGroupInterface class KrtekFixtures extends Fixture
{ {
public const string KRTEK_SEASON = 'krtek-seaspm';
public static function getGroups(): array
{
return ['test', 'dev'];
}
public function load(ObjectManager $manager): void public function load(ObjectManager $manager): void
{ {
$season = new Season(); $season = new Season();
$manager->persist($season); $manager->persist($season);
$season->name = 'Krtek Weekend'; $season->setName('Krtek Weekend')
$season->seasonCode = 'krtek'; ->setSeasonCode('krtek')
$season
->addCandidate(new Candidate('Claudia')) ->addCandidate(new Candidate('Claudia'))
->addCandidate(new Candidate('Eelco')) ->addCandidate(new Candidate('Eelco'))
->addCandidate(new Candidate('Elise')) ->addCandidate(new Candidate('Elise'))
@@ -44,56 +35,53 @@ final class KrtekFixtures extends Fixture implements FixtureGroupInterface
->addCandidate(new Candidate('Robbert')) ->addCandidate(new Candidate('Robbert'))
->addCandidate(new Candidate('Tom')); ->addCandidate(new Candidate('Tom'));
$quiz1 = $this->createQuiz1($season); $quiz1 = $this->createQuiz1($season);
$season->addQuiz($quiz1); $season->addQuiz($quiz1)
$season->activeQuiz = $quiz1; ->setActiveQuiz($quiz1)
$season->addQuiz($this->createQuiz2($season)); ->addQuiz($this->createQuiz2($season));
$manager->flush(); $manager->flush();
$this->addReference(self::KRTEK_SEASON, $season);
} }
private function createQuiz1(Season $season): Quiz private function createQuiz1(Season $season): Quiz
{ {
$quiz = new Quiz(); return new Quiz()
$quiz->name = 'Quiz 1'; ->setName('Quiz 1')
$quiz->season = $season; ->setSeason($season)
$q = new Question(); ->addQuestion(new Question()
$q->question = 'Is de Krtek een man of een vrouw?'; ->setQuestion('Is de Krtek een man of een vrouw?')
$q->addAnswer(new Answer('Vrouw', true)) ->addAnswer(new Answer('Vrouw', true))
->addAnswer(new Answer('Man')); ->addAnswer(new Answer('Man'))
$q->ordering = 1; ->setOrdering(1),
$quiz->addQuestion($q); )
$q = new Question(); ->addQuestion(new Question()
$q->question = 'Hoeveel broers heeft de Krtek?'; ->setQuestion('Hoeveel broers heeft de Krtek?')
$q->addAnswer(new Answer('Geen', true)) ->addAnswer(new Answer('Geen', true))
->addAnswer(new Answer('1')) ->addAnswer(new Answer('1'))
->addAnswer(new Answer('2')); ->addAnswer(new Answer('2'))
$q->ordering = 2; ->setOrdering(2),
$quiz->addQuestion($q); )
$q = new Question(); ->addQuestion(new Question()
$q->question = 'Wat is de lievelingsfeestdag van de Krtek?'; ->setQuestion('Wat is de lievelingsfeestdag van de Krtek?')
$q->addAnswer(new Answer('Geen')) ->addAnswer(new Answer('Geen'))
->addAnswer(new Answer('Diens eigen verjaardag')) ->addAnswer(new Answer('Diens eigen verjaardag'))
->addAnswer(new Answer('Koningsdag')) ->addAnswer(new Answer('Koningsdag'))
->addAnswer(new Answer('Kerst', true)) ->addAnswer(new Answer('Kerst', true))
->addAnswer(new Answer('Oud en Nieuw')); ->addAnswer(new Answer('Oud en Nieuw'))
$q->ordering = 3; ->setOrdering(3),
$quiz->addQuestion($q); )
$q = new Question(); ->addQuestion(new Question()
$q->question = 'Hoe kwam de Krtek naar Kersteren vandaag?'; ->setQuestion('Hoe kwam de Krtek naar Kersteren vandaag?')
$q->addAnswer(new Answer('Met het OV', true)) ->addAnswer(new Answer('Met het OV', true))
->addAnswer(new Answer('Met de auto')); ->addAnswer(new Answer('Met de auto'))
$q->ordering = 4; ->setOrdering(4),
$quiz->addQuestion($q); )
->addQuestion(new Question()
$q = new Question(); ->setQuestion('Met wie keek de Krtek video bij binnenkomst?')
$q->question = 'Met wie keek de Krtek video bij binnenkomst?'; ->addAnswer(new Answer('Claudia'))
$q->addAnswer(new Answer('Claudia'))
->addAnswer(new Answer('Eelco')) ->addAnswer(new Answer('Eelco'))
->addAnswer(new Answer('Elise')) ->addAnswer(new Answer('Elise'))
->addAnswer(new Answer('Gert-Jan')) ->addAnswer(new Answer('Gert-Jan'))
@@ -105,52 +93,52 @@ final class KrtekFixtures extends Fixture implements FixtureGroupInterface
->addAnswer(new Answer('Philine')) ->addAnswer(new Answer('Philine'))
->addAnswer(new Answer('Remy')) ->addAnswer(new Answer('Remy'))
->addAnswer(new Answer('Robbert')) ->addAnswer(new Answer('Robbert'))
->addAnswer(new Answer('Tom', true)); ->addAnswer(new Answer('Tom', true))
$q->ordering = 5; ->setOrdering(5),
$quiz->addQuestion($q); )
$q = new Question(); ->addQuestion(new Question()
$q->question = 'Welk advies zou de Krtek zichzelf als kind geven?'; ->setQuestion('Welk advies zou de Krtek zichzelf als kind geven?')
$q->addAnswer(new Answer('Geef je vader een knuffel.')) ->addAnswer(new Answer('Geef je vader een knuffel.'))
->addAnswer(new Answer('Trek je wat minder aan van anderen.')) ->addAnswer(new Answer('Trek je wat minder aan van anderen.'))
->addAnswer(new Answer('Luister meer naar je eigen gevoel in plaats van naar wat anderen vinden.')) ->addAnswer(new Answer('Luister meer naar je eigen gevoel in plaats van naar wat anderen vinden.'))
->addAnswer(new Answer('Stel niet alles tot het laatste moment uit.')) ->addAnswer(new Answer('Stel niet alles tot het laatste moment uit.'))
->addAnswer(new Answer('Altijd doorgaan.')) ->addAnswer(new Answer('Altijd doorgaan.'))
->addAnswer(new Answer('Probeer ook eens buiten de lijntjes te kleuren', true)) ->addAnswer(new Answer('Probeer ook eens buiten de lijntjes te kleuren', true))
->addAnswer(new Answer('Ga als je groot bent op groepsreis! ')) ->addAnswer(new Answer('Ga als je groot bent op groepsreis! '))
->addAnswer(new Answer('Trek minder aan van de mening van anderen, het is oké om anders te zijn.')); ->addAnswer(new Answer('Trek minder aan van de mening van anderen, het is oké om anders te zijn.'))
$q->ordering = 6; ->setOrdering(6),
$quiz->addQuestion($q); )
$q = new Question(); ->addQuestion(new Question()
$q->question = 'Wat voor soort schoenen droeg de Krtek bij het diner?'; ->setQuestion('Wat voor soort schoenen droeg de Krtek bij het diner?')
$q->addAnswer(new Answer('Sneakers')) ->addAnswer(new Answer('Sneakers'))
->addAnswer(new Answer('Wandel-/bergschoenen', true)) ->addAnswer(new Answer('Wandel-/bergschoenen', true))
->addAnswer(new Answer('Lederen schoenen')) ->addAnswer(new Answer('Lederen schoenen'))
->addAnswer(new Answer('Pantoffels')) ->addAnswer(new Answer('Pantoffels'))
->addAnswer(new Answer('Hakken')) ->addAnswer(new Answer('Hakken'))
->addAnswer(new Answer('Geen schoenen, alleen sokken')); ->addAnswer(new Answer('Geen schoenen, alleen sokken'))
$q->ordering = 7; ->setOrdering(7),
$quiz->addQuestion($q); )
$q = new Question(); ->addQuestion(new Question()
$q->question = 'Met welk vervoersmiddel reist de Krtek het liefste?'; ->setQuestion('Met welk vervoersmiddel reist de Krtek het liefste?')
$q->addAnswer(new Answer('Fiets', true)) ->addAnswer(new Answer('Fiets', true))
->addAnswer(new Answer('Auto')) ->addAnswer(new Answer('Auto'))
->addAnswer(new Answer('Trein')); ->addAnswer(new Answer('Trein'))
$q->ordering = 8; ->setOrdering(8),
$quiz->addQuestion($q); )
$q = new Question(); ->addQuestion(new Question()
$q->question = 'Heeft de Krtek een eigen auto?'; ->setQuestion('Heeft de Krtek een eigen auto?')
$q->addAnswer(new Answer('Ja')) ->addAnswer(new Answer('Ja'))
->addAnswer(new Answer('Nee', true)); ->addAnswer(new Answer('Nee', true))
$q->ordering = 9; ->setOrdering(9),
$quiz->addQuestion($q); )
$q = new Question(); ->addQuestion(new Question()
$q->question = 'Van wie is de quote die de Krtek gepakt heeft'; ->setQuestion('Van wie is de quote die de Krtek gepakt heeft')
$q->addAnswer(new Answer('Karen')) ->addAnswer(new Answer('Karen'))
->addAnswer(new Answer('Gilles de Coster')) ->addAnswer(new Answer('Gilles de Coster'))
->addAnswer(new Answer('Kees Tol')) ->addAnswer(new Answer('Kees Tol'))
->addAnswer(new Answer('Harry en John')) ->addAnswer(new Answer('Harry en John'))
@@ -164,44 +152,44 @@ final class KrtekFixtures extends Fixture implements FixtureGroupInterface
->addAnswer(new Answer('Karin de Groot')) ->addAnswer(new Answer('Karin de Groot'))
->addAnswer(new Answer('Pieter')) ->addAnswer(new Answer('Pieter'))
->addAnswer(new Answer('Renée Fokker')) ->addAnswer(new Answer('Renée Fokker'))
->addAnswer(new Answer('Sam, Davy', true)); ->addAnswer(new Answer('Sam, Davy', true))
$q->ordering = 10; ->setOrdering(10),
$quiz->addQuestion($q); )
$q = new Question(); ->addQuestion(new Question()
$q->question = 'Zou de Krtek molboekjes, jokers, vrijstellingen of topitos uit iemands rugzak stelen om te kunnen winnen?'; ->setQuestion('Zou de Krtek molboekjes, jokers, vrijstellingen of topitos uit iemands rugzak stelen om te kunnen winnen?')
$q->addAnswer(new Answer('Ja')) ->addAnswer(new Answer('Ja'))
->addAnswer(new Answer('Nee', true)); ->addAnswer(new Answer('Nee', true))
$q->ordering = 11; ->setOrdering(11),
$quiz->addQuestion($q); )
$q = new Question(); ->addQuestion(new Question()
$q->question = 'In wat voor bed slaapt de Krtek dit weekend?'; ->setQuestion('In wat voor bed slaapt de Krtek dit weekend?')
$q->addAnswer(new Answer('Éénpersoons, losstaand bed')) ->addAnswer(new Answer('Éénpersoons, losstaand bed'))
->addAnswer(new Answer('Éénpersoonsbed, tegen een ander bed aan', true)) ->addAnswer(new Answer('Éénpersoonsbed, tegen een ander bed aan', true))
->addAnswer(new Answer('Tweepersoons bed')); ->addAnswer(new Answer('Tweepersoons bed'))
$q->ordering = 12; ->setOrdering(12),
$quiz->addQuestion($q); )
$q = new Question(); ->addQuestion(new Question()
$q->question = 'Hoeveel jaar heeft de Krtek gedaan over de middelbare school?'; ->setQuestion('Hoeveel jaar heeft de Krtek gedaan over de middelbare school?')
$q->addAnswer(new Answer('5')) ->addAnswer(new Answer('5'))
->addAnswer(new Answer('6', true)) ->addAnswer(new Answer('6', true))
->addAnswer(new Answer('7')) ->addAnswer(new Answer('7'))
->addAnswer(new Answer('8')); ->addAnswer(new Answer('8'))
$q->ordering = 13; ->setOrdering(13),
$quiz->addQuestion($q); )
$q = new Question(); ->addQuestion(new Question()
$q->question = 'Waar zat de Krtek aan tafel bij het diner?'; ->setQuestion('Waar zat de Krtek aan tafel bij het diner?')
$q->addAnswer(new Answer('Met de rug naar de accommodatie')) ->addAnswer(new Answer('Met de rug naar de accommodatie'))
->addAnswer(new Answer('Met de rug naar de buitenmuur', true)); ->addAnswer(new Answer('Met de rug naar de buitenmuur', true))
$q->ordering = 14; ->setOrdering(14),
$quiz->addQuestion($q); )
$q = new Question(); ->addQuestion(new Question()
$q->question = 'Wie is de Krtek?'; ->setQuestion('Wie is de Krtek?')
$q->addAnswer(new Answer('Claudia', true)) ->addAnswer(new Answer('Claudia', true))
->addAnswer(new Answer('Eelco')) ->addAnswer(new Answer('Eelco'))
->addAnswer(new Answer('Elise')) ->addAnswer(new Answer('Elise'))
->addAnswer(new Answer('Gert-Jan')) ->addAnswer(new Answer('Gert-Jan'))
@@ -213,159 +201,158 @@ final class KrtekFixtures extends Fixture implements FixtureGroupInterface
->addAnswer(new Answer('Philine')) ->addAnswer(new Answer('Philine'))
->addAnswer(new Answer('Remy')) ->addAnswer(new Answer('Remy'))
->addAnswer(new Answer('Robbert')) ->addAnswer(new Answer('Robbert'))
->addAnswer(new Answer('Tom')); ->addAnswer(new Answer('Tom'))
$q->ordering = 15; ->setOrdering(15),
$quiz->addQuestion($q); )
;
return $quiz;
} }
private function createQuiz2(Season $season): Quiz private function createQuiz2(Season $season): Quiz
{ {
$quiz = new Quiz(); return new Quiz()
$quiz->name = 'Quiz 2'; ->setName('Quiz 2')
$quiz->season = $season; ->setSeason($season)
$q = new Question(); ->addQuestion(new Question()
$q->question = 'Is de Krtek een man of een vrouw?'; ->setQuestion('Is de Krtek een man of een vrouw?')
$q->addAnswer(new Answer('Man')) ->addAnswer(new Answer('Man'))
->addAnswer(new Answer('Vrouw', true)); ->addAnswer(new Answer('Vrouw', true))
$q->ordering = 1; ->setOrdering(1),
$quiz->addQuestion($q); )
$q = new Question(); ->addQuestion(new Question()
$q->question = 'Heeft de Krtek dieetwensen of allergieën?'; ->setQuestion('Heeft de Krtek dieetwensen of allergieën?')
$q->addAnswer(new Answer('nee')) ->addAnswer(new Answer('nee'))
->addAnswer(new Answer('De Krtek is vegetariër', true)) ->addAnswer(new Answer('De Krtek is vegetariër', true))
->addAnswer(new Answer('De Krtek is flexitariër')) ->addAnswer(new Answer('De Krtek is flexitariër'))
->addAnswer(new Answer('De Krtek heeft een allergie')) ->addAnswer(new Answer('De Krtek heeft een allergie'))
->addAnswer(new Answer('De Krtek heeft een intolerantie')) ->addAnswer(new Answer('De Krtek heeft een intolerantie'))
->addAnswer(new Answer('De Krtek eet geen rundvlees')) ->addAnswer(new Answer('De Krtek eet geen rundvlees'))
->addAnswer(new Answer('De Krtek eet geen waterdieren')); ->addAnswer(new Answer('De Krtek eet geen waterdieren'))
$q->ordering = 2; ->setOrdering(2),
$quiz->addQuestion($q); )
$q = new Question(); ->addQuestion(new Question()
$q->question = 'Hoe heet het huisdier/de huisdieren van de Krtek?'; ->setQuestion('Hoe heet het huisdier/de huisdieren van de Krtek?')
$q->addAnswer(new Answer('Amy, Karel en Floyd')) ->addAnswer(new Answer('Amy, Karel en Floyd'))
->addAnswer(new Answer('Flip en Majoor')) ->addAnswer(new Answer('Flip en Majoor'))
->addAnswer(new Answer('Benji')) ->addAnswer(new Answer('Benji'))
->addAnswer(new Answer('Sini')) ->addAnswer(new Answer('Sini'))
->addAnswer(new Answer('Tom')) ->addAnswer(new Answer('Tom'))
->addAnswer(new Answer('De huisdieren van de Krtek hebben geen naam')) ->addAnswer(new Answer('De huisdieren van de Krtek hebben geen naam'))
->addAnswer(new Answer('De Krtek heeft geen huisdieren', true)); ->addAnswer(new Answer('De Krtek heeft geen huisdieren', true))
$q->ordering = 3; ->setOrdering(3),
$quiz->addQuestion($q); )
$q = new Question(); ->addQuestion(new Question()
$q->question = 'Wat dronk de Krtek deze ochtend bij het ontbijt?'; ->setQuestion('Wat dronk de Krtek deze ochtend bij het ontbijt?')
$q->addAnswer(new Answer('Koffie')) ->addAnswer(new Answer('Koffie'))
->addAnswer(new Answer('Thee')) ->addAnswer(new Answer('Thee'))
->addAnswer(new Answer('Water', true)) ->addAnswer(new Answer('Water', true))
->addAnswer(new Answer('Melk')) ->addAnswer(new Answer('Melk'))
->addAnswer(new Answer('Sap')) ->addAnswer(new Answer('Sap'))
->addAnswer(new Answer('Niks')); ->addAnswer(new Answer('Niks'))
$q->ordering = 4; ->setOrdering(4),
$quiz->addQuestion($q); )
$q = new Question(); ->addQuestion(new Question()
$q->question = 'Waar ging de eerste vakantie die de Krtek zich nog herinnert heen?'; ->setQuestion('Waar ging de eerste vakantie die de Krtek zich nog herinnert heen?')
$q->addAnswer(new Answer('Denemarken')) ->addAnswer(new Answer('Denemarken'))
->addAnswer(new Answer('Drenthe')) ->addAnswer(new Answer('Drenthe'))
->addAnswer(new Answer('Mallorca')) ->addAnswer(new Answer('Mallorca'))
->addAnswer(new Answer('Marokko')) ->addAnswer(new Answer('Marokko'))
->addAnswer(new Answer('Oostenrijk')) ->addAnswer(new Answer('Oostenrijk'))
->addAnswer(new Answer('Turkije')) ->addAnswer(new Answer('Turkije'))
->addAnswer(new Answer('Zweden', true)); ->addAnswer(new Answer('Zweden', true))
$q->ordering = 5; ->setOrdering(5),
$quiz->addQuestion($q); )
$q = new Question(); ->addQuestion(new Question()
$q->question = 'Met welk groepje ging de Krtek als eerste het Douanespel in?'; ->setQuestion('Met welk groepje ging de Krtek als eerste het Douanespel in?')
$q->addAnswer(new Answer('Het eerste groepje', true)) ->addAnswer(new Answer('Het eerste groepje', true))
->addAnswer(new Answer('Het tweede groepje')) ->addAnswer(new Answer('Het tweede groepje'))
->addAnswer(new Answer('Het derde groepje')) ->addAnswer(new Answer('Het derde groepje'))
->addAnswer(new Answer('Het vierde groepje')) ->addAnswer(new Answer('Het vierde groepje'))
->addAnswer(new Answer('Het vijfde groepje')); ->addAnswer(new Answer('Het vijfde groepje'))
$q->ordering = 6; ->setOrdering(6),
$quiz->addQuestion($q); )
$q = new Question(); ->addQuestion(new Question()
$q->question = 'Gelooft de Krtek ergens in?'; ->setQuestion('Gelooft de Krtek ergens in?')
$q->addAnswer(new Answer('Nee')) ->addAnswer(new Answer('Nee'))
->addAnswer(new Answer('Het universum', true)) ->addAnswer(new Answer('Het universum', true))
->addAnswer(new Answer('Toeval')) ->addAnswer(new Answer('Toeval'))
->addAnswer(new Answer('De Krtek is hindoeïstisch')); ->addAnswer(new Answer('De Krtek is hindoeïstisch'))
$q->ordering = 7; ->setOrdering(7),
$quiz->addQuestion($q); )
$q = new Question(); ->addQuestion(new Question()
$q->question = 'At de Krtek op vrijdagavond heksenkaas tijdens het diner?'; ->setQuestion('At de Krtek op vrijdagavond heksenkaas tijdens het diner?')
$q->addAnswer(new Answer('Ja', true)) ->addAnswer(new Answer('Ja', true))
->addAnswer(new Answer('Nee')); ->addAnswer(new Answer('Nee'))
$q->ordering = 8; ->setOrdering(8),
$quiz->addQuestion($q); )
$q = new Question(); ->addQuestion(new Question()
$q->question = 'Hoe laat ging de Krtek gisteravond naar bed?'; ->setQuestion('Hoe laat ging de Krtek gisteravond naar bed?')
$q->addAnswer(new Answer('Tussen 0:00 en 0:59 uur')) ->addAnswer(new Answer('Tussen 0:00 en 0:59 uur'))
->addAnswer(new Answer('Tussen 1:00 en 1:59 uur', true)) ->addAnswer(new Answer('Tussen 1:00 en 1:59 uur', true))
->addAnswer(new Answer('Tussen 2:00 en 2:59 uur')) ->addAnswer(new Answer('Tussen 2:00 en 2:59 uur'))
->addAnswer(new Answer('Na 3:00')); ->addAnswer(new Answer('Na 3:00'))
$q->ordering = 9; ->setOrdering(9),
$quiz->addQuestion($q); )
$q = new Question(); ->addQuestion(new Question()
$q->question = 'Hoeveel batterijen heeft de Krtek naar het bord gebracht bij het douanespel?'; ->setQuestion('Hoeveel batterijen heeft de Krtek naar het bord gebracht bij het douanespel?')
$q->addAnswer(new Answer('1')) ->addAnswer(new Answer('1'))
->addAnswer(new Answer('2')) ->addAnswer(new Answer('2'))
->addAnswer(new Answer('3')) ->addAnswer(new Answer('3'))
->addAnswer(new Answer('geen', true)); ->addAnswer(new Answer('geen', true))
$q->ordering = 10; ->setOrdering(10),
$quiz->addQuestion($q); )
$q = new Question(); ->addQuestion(new Question()
$q->question = 'Wat keek de Krtek als kind graag op TV?'; ->setQuestion('Wat keek de Krtek als kind graag op TV?')
$q->addAnswer(new Answer('Digimon', true)) ->addAnswer(new Answer('Digimon', true))
->addAnswer(new Answer('Floris')) ->addAnswer(new Answer('Floris'))
->addAnswer(new Answer('Het huis Anubis')) ->addAnswer(new Answer('Het huis Anubis'))
->addAnswer(new Answer('Sesamstraat')) ->addAnswer(new Answer('Sesamstraat'))
->addAnswer(new Answer('Spongebob Squarepants')) ->addAnswer(new Answer('Spongebob Squarepants'))
->addAnswer(new Answer('Teletubbies')); ->addAnswer(new Answer('Teletubbies'))
$q->ordering = 11; ->setOrdering(11),
$quiz->addQuestion($q); )
$q = new Question(); ->addQuestion(new Question()
$q->question = 'Waarin zat op de heenreis de bagage van de Krtek (voornamelijk)?'; ->setQuestion('Waarin zat op de heenreis de bagage van de Krtek (voornamelijk)?')
$q->addAnswer(new Answer('In koffer(s)', true)) ->addAnswer(new Answer('In koffer(s)', true))
->addAnswer(new Answer('In losse tas(sen)')) ->addAnswer(new Answer('In losse tas(sen)'))
->addAnswer(new Answer('In een rugzak')); ->addAnswer(new Answer('In een rugzak'))
$q->ordering = 12; ->setOrdering(12),
$quiz->addQuestion($q); )
$q = new Question(); ->addQuestion(new Question()
$q->question = 'Van welk geluid gaan de haren van de Krtek overeind staan?'; ->setQuestion('Van welk geluid gaan de haren van de Krtek overeind staan?')
$q->addAnswer(new Answer('Een vork die door een metalen pan krast ')) ->addAnswer(new Answer('Een vork die door een metalen pan krast '))
->addAnswer(new Answer('Smakkende mensen')) ->addAnswer(new Answer('Smakkende mensen'))
->addAnswer(new Answer('Een vork die over een bord schraapt')) ->addAnswer(new Answer('Een vork die over een bord schraapt'))
->addAnswer(new Answer('Schuren met schuurpapier')) ->addAnswer(new Answer('Schuren met schuurpapier'))
->addAnswer(new Answer('Nagels op een krijtbord')) ->addAnswer(new Answer('Nagels op een krijtbord'))
->addAnswer(new Answer('Servies dat tegen elkaar klettert')) ->addAnswer(new Answer('Servies dat tegen elkaar klettert'))
->addAnswer(new Answer('Het geroekoe van een duif', true)) ->addAnswer(new Answer('Het geroekoe van een duif', true))
->addAnswer(new Answer('Piepschuim')); ->addAnswer(new Answer('Piepschuim'))
$q->ordering = 13; ->setOrdering(13),
$quiz->addQuestion($q); )
$q = new Question(); ->addQuestion(new Question()
$q->question = 'Wilde de Krtek penningmeester worden?'; ->setQuestion('Wilde de Krtek penningmeester worden?')
$q->addAnswer(new Answer('Ja')) ->addAnswer(new Answer('Ja'))
->addAnswer(new Answer('Nee', true)); ->addAnswer(new Answer('Nee', true))
$q->ordering = 14; ->setOrdering(14),
$quiz->addQuestion($q); )
$q = new Question(); ->addQuestion(new Question()
$q->question = 'Wie is de Krtek?'; ->setQuestion('Wie is de Krtek?')
$q->addAnswer(new Answer('Claudia', true)) ->addAnswer(new Answer('Claudia', true))
->addAnswer(new Answer('Eelco')) ->addAnswer(new Answer('Eelco'))
->addAnswer(new Answer('Elise')) ->addAnswer(new Answer('Elise'))
->addAnswer(new Answer('Gert-Jan')) ->addAnswer(new Answer('Gert-Jan'))
@@ -377,10 +364,9 @@ final class KrtekFixtures extends Fixture implements FixtureGroupInterface
->addAnswer(new Answer('Philine')) ->addAnswer(new Answer('Philine'))
->addAnswer(new Answer('Remy')) ->addAnswer(new Answer('Remy'))
->addAnswer(new Answer('Robbert')) ->addAnswer(new Answer('Robbert'))
->addAnswer(new Answer('Tom')); ->addAnswer(new Answer('Tom'))
$q->ordering = 15; ->setOrdering(15),
$quiz->addQuestion($q); )
;
return $quiz;
} }
} }

View File

@@ -1,75 +0,0 @@
<?php
declare(strict_types=1);
namespace Tvdt\DataFixtures;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Bundle\FixturesBundle\FixtureGroupInterface;
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
use Doctrine\Persistence\ObjectManager;
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
use Tvdt\Entity\Season;
use Tvdt\Entity\User;
final class TestFixtures extends Fixture implements FixtureGroupInterface, DependentFixtureInterface
{
public const string PASSWORD = 'test1234';
public function __construct(
private readonly UserPasswordHasherInterface $passwordHasher,
) {}
public static function getGroups(): array
{
return ['test'];
}
public function getDependencies(): array
{
return [KrtekFixtures::class];
}
public function load(ObjectManager $manager): void
{
$user = new User();
$user->email = 'test@example.org';
$user->password = $this->passwordHasher->hashPassword($user, self::PASSWORD);
$manager->persist($user);
$user = new User();
$user->email = 'krtek-admin@example.org';
$user->password = $this->passwordHasher->hashPassword($user, self::PASSWORD);
$manager->persist($user);
$krtek = $this->getReference(KrtekFixtures::KRTEK_SEASON, Season::class);
$krtek->addOwner($user);
$anotherSeason = new Season();
$anotherSeason->name = 'Another Season';
$anotherSeason->seasonCode = 'bbbbb';
$manager->persist($anotherSeason);
$this->addReference('another-season', $anotherSeason);
$user = new User();
$user->email = 'user1@example.org';
$user->password = $this->passwordHasher->hashPassword($user, self::PASSWORD);
$manager->persist($user);
$user->addSeason($anotherSeason);
$user = new User();
$user->email = 'user2@example.org';
$user->password = $this->passwordHasher->hashPassword($user, self::PASSWORD);
$manager->persist($user);
$krtek->addOwner($user);
$anotherSeason->addOwner($user);
$manager->flush();
}
}

View File

@@ -1,19 +0,0 @@
<?php
declare(strict_types=1);
namespace Tvdt\Dto;
use Symfony\Component\Uid\Uuid;
final readonly class Result
{
public function __construct(
public Uuid $id,
public string $name,
public int $correct,
public float $corrections,
public \DateInterval $time,
public float $score,
) {}
}

View File

@@ -8,6 +8,7 @@ use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types; use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
use Symfony\Bridge\Doctrine\Types\UuidType; use Symfony\Bridge\Doctrine\Types\UuidType;
use Symfony\Component\Uid\Uuid; use Symfony\Component\Uid\Uuid;
use Tvdt\Repository\AnswerRepository; use Tvdt\Repository\AnswerRepository;
@@ -16,45 +17,114 @@ use Tvdt\Repository\AnswerRepository;
class Answer class Answer
{ {
#[ORM\Column(type: UuidType::NAME)] #[ORM\Column(type: UuidType::NAME)]
#[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')] #[ORM\CustomIdGenerator(class: UuidGenerator::class)]
#[ORM\GeneratedValue(strategy: 'CUSTOM')] #[ORM\GeneratedValue(strategy: 'CUSTOM')]
#[ORM\Id] #[ORM\Id]
public private(set) Uuid $id; private Uuid $id;
#[ORM\Column(type: Types::SMALLINT, options: ['default' => 0])] #[ORM\Column(type: Types::SMALLINT, options: ['default' => 0])]
public int $ordering = 0; private int $ordering = 0;
#[ORM\JoinColumn(nullable: false)] #[ORM\JoinColumn(nullable: false)]
#[ORM\ManyToOne(inversedBy: 'answers')] #[ORM\ManyToOne(inversedBy: 'answers')]
public Question $question; private Question $question;
/** @var Collection<int, Candidate> */ /** @var Collection<int, Candidate> */
#[ORM\ManyToMany(targetEntity: Candidate::class, inversedBy: 'answersOnCandidate')] #[ORM\ManyToMany(targetEntity: Candidate::class, inversedBy: 'answersOnCandidate')]
public private(set) Collection $candidates; private Collection $candidates;
/** @var Collection<int, GivenAnswer> */ /** @var Collection<int, GivenAnswer> */
#[ORM\OneToMany(targetEntity: GivenAnswer::class, mappedBy: 'answer', orphanRemoval: true)] #[ORM\OneToMany(targetEntity: GivenAnswer::class, mappedBy: 'answer', orphanRemoval: true)]
public private(set) Collection $givenAnswers; private Collection $givenAnswers;
public function __construct( public function __construct(
#[ORM\Column(length: 255)] #[ORM\Column(length: 255)]
public string $text, private string $text,
#[ORM\Column] #[ORM\Column]
public bool $isRightAnswer = false, private bool $isRightAnswer = false,
) { ) {
$this->candidates = new ArrayCollection(); $this->candidates = new ArrayCollection();
$this->givenAnswers = new ArrayCollection(); $this->givenAnswers = new ArrayCollection();
} }
public function addCandidate(Candidate $candidate): void public function getId(): Uuid
{
return $this->id;
}
public function getText(): string
{
return $this->text;
}
public function setText(string $text): static
{
$this->text = $text;
return $this;
}
public function getQuestion(): Question
{
return $this->question;
}
public function setQuestion(Question $question): static
{
$this->question = $question;
return $this;
}
public function isRightAnswer(): bool
{
return $this->isRightAnswer;
}
public function setRightAnswer(bool $isRightAnswer): static
{
$this->isRightAnswer = $isRightAnswer;
return $this;
}
/** @return Collection<int, Candidate> */
public function getCandidates(): Collection
{
return $this->candidates;
}
public function addCandidate(Candidate $candidate): static
{ {
if (!$this->candidates->contains($candidate)) { if (!$this->candidates->contains($candidate)) {
$this->candidates->add($candidate); $this->candidates->add($candidate);
} }
return $this;
} }
public function removeCandidate(Candidate $candidate): void public function removeCandidate(Candidate $candidate): static
{ {
$this->candidates->removeElement($candidate); $this->candidates->removeElement($candidate);
return $this;
}
/** @return Collection<int, GivenAnswer> */
public function getGivenAnswers(): Collection
{
return $this->givenAnswers;
}
public function getOrdering(): int
{
return $this->ordering;
}
public function setOrdering(int $ordering): self
{
$this->ordering = $ordering;
return $this;
} }
} }

View File

@@ -7,6 +7,7 @@ namespace Tvdt\Entity;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
use Symfony\Bridge\Doctrine\Types\UuidType; use Symfony\Bridge\Doctrine\Types\UuidType;
use Symfony\Component\Uid\Uuid; use Symfony\Component\Uid\Uuid;
use Tvdt\Helpers\Base64; use Tvdt\Helpers\Base64;
@@ -17,52 +18,104 @@ use Tvdt\Repository\CandidateRepository;
class Candidate class Candidate
{ {
#[ORM\Column(type: UuidType::NAME, unique: true)] #[ORM\Column(type: UuidType::NAME, unique: true)]
#[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')] #[ORM\CustomIdGenerator(class: UuidGenerator::class)]
#[ORM\GeneratedValue(strategy: 'CUSTOM')] #[ORM\GeneratedValue(strategy: 'CUSTOM')]
#[ORM\Id] #[ORM\Id]
public private(set) Uuid $id; private Uuid $id;
#[ORM\JoinColumn(nullable: false)] #[ORM\JoinColumn(nullable: false)]
#[ORM\ManyToOne(inversedBy: 'candidates')] #[ORM\ManyToOne(inversedBy: 'candidates')]
public Season $season; private Season $season;
/** @var Collection<int, Answer> */ /** @var Collection<int, Answer> */
#[ORM\ManyToMany(targetEntity: Answer::class, mappedBy: 'candidates')] #[ORM\ManyToMany(targetEntity: Answer::class, mappedBy: 'candidates')]
public private(set) Collection $answersOnCandidate; private Collection $answersOnCandidate;
/** @var Collection<int, GivenAnswer> */ /** @var Collection<int, GivenAnswer> */
#[ORM\OneToMany(targetEntity: GivenAnswer::class, mappedBy: 'candidate', orphanRemoval: true)] #[ORM\OneToMany(targetEntity: GivenAnswer::class, mappedBy: 'candidate', orphanRemoval: true)]
public private(set) Collection $givenAnswers; private Collection $givenAnswers;
/** @var Collection<int, QuizCandidate> */ /** @var Collection<int, QuizCandidate> */
#[ORM\OneToMany(targetEntity: QuizCandidate::class, mappedBy: 'candidate', orphanRemoval: true)] #[ORM\OneToMany(targetEntity: QuizCandidate::class, mappedBy: 'candidate', orphanRemoval: true)]
public private(set) Collection $quizData; private Collection $quizData;
public string $nameHash {
get => Base64::base64UrlEncode($this->name);
}
public function __construct( public function __construct(
#[ORM\Column(length: 16)] #[ORM\Column(length: 16)]
public string $name, private string $name,
) { ) {
$this->answersOnCandidate = new ArrayCollection(); $this->answersOnCandidate = new ArrayCollection();
$this->givenAnswers = new ArrayCollection(); $this->givenAnswers = new ArrayCollection();
$this->quizData = new ArrayCollection(); $this->quizData = new ArrayCollection();
} }
public function addAnswersOnCandidate(Answer $answersOnCandidate): void public function getId(): Uuid
{
return $this->id;
}
public function getSeason(): Season
{
return $this->season;
}
public function setSeason(Season $season): static
{
$this->season = $season;
return $this;
}
public function getName(): string
{
return $this->name;
}
public function setName(string $name): static
{
$this->name = $name;
return $this;
}
/** @return Collection<int, Answer> */
public function getAnswersOnCandidate(): Collection
{
return $this->answersOnCandidate;
}
public function addAnswersOnCandidate(Answer $answersOnCandidate): static
{ {
if (!$this->answersOnCandidate->contains($answersOnCandidate)) { if (!$this->answersOnCandidate->contains($answersOnCandidate)) {
$this->answersOnCandidate->add($answersOnCandidate); $this->answersOnCandidate->add($answersOnCandidate);
$answersOnCandidate->addCandidate($this); $answersOnCandidate->addCandidate($this);
} }
return $this;
} }
public function removeAnswersOnCandidate(Answer $answersOnCandidate): void public function removeAnswersOnCandidate(Answer $answersOnCandidate): static
{ {
if ($this->answersOnCandidate->removeElement($answersOnCandidate)) { if ($this->answersOnCandidate->removeElement($answersOnCandidate)) {
$answersOnCandidate->removeCandidate($this); $answersOnCandidate->removeCandidate($this);
} }
return $this;
}
/** @return Collection<int, GivenAnswer> */
public function getGivenAnswers(): Collection
{
return $this->givenAnswers;
}
/** @return Collection<int, QuizCandidate> */
public function getQuizData(): Collection
{
return $this->quizData;
}
public function getNameHash(): string
{
return Base64::base64UrlEncode($this->name);
} }
} }

View File

@@ -6,7 +6,8 @@ namespace Tvdt\Entity;
use Doctrine\DBAL\Types\Types; use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo; use Safe\DateTimeImmutable;
use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
use Symfony\Bridge\Doctrine\Types\UuidType; use Symfony\Bridge\Doctrine\Types\UuidType;
use Symfony\Component\HttpFoundation\InputBag; use Symfony\Component\HttpFoundation\InputBag;
use Symfony\Component\Uid\Uuid; use Symfony\Component\Uid\Uuid;
@@ -21,25 +22,48 @@ class Elimination
public const string SCREEN_RED = 'red'; public const string SCREEN_RED = 'red';
#[ORM\Column(type: UuidType::NAME, unique: true)] #[ORM\Column(type: UuidType::NAME, unique: true)]
#[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')] #[ORM\CustomIdGenerator(class: UuidGenerator::class)]
#[ORM\GeneratedValue(strategy: 'CUSTOM')] #[ORM\GeneratedValue(strategy: 'CUSTOM')]
#[ORM\Id] #[ORM\Id]
public private(set) Uuid $id; private Uuid $id;
/** @var array<string, mixed> */ /** @var array<string, mixed> */
#[ORM\Column(type: Types::JSONB)] #[ORM\Column(type: Types::JSON)]
public array $data = []; private array $data = [];
#[Gedmo\Timestampable(on: 'create')]
#[ORM\Column(type: Types::DATETIMETZ_IMMUTABLE, nullable: false)] #[ORM\Column(type: Types::DATETIMETZ_IMMUTABLE, nullable: false)]
public private(set) \DateTimeImmutable $created; private \DateTimeImmutable $created;
public function __construct( public function __construct(
#[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')] #[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
#[ORM\ManyToOne(inversedBy: 'eliminations')] #[ORM\ManyToOne(inversedBy: 'eliminations')]
public Quiz $quiz, private Quiz $quiz,
) {} ) {}
public function getId(): Uuid
{
return $this->id;
}
/** @return array<string, mixed> */
public function getData(): array
{
return $this->data;
}
/** @param array<string, mixed> $data */
public function setData(array $data): self
{
$this->data = $data;
return $this;
}
public function getQuiz(): Quiz
{
return $this->quiz;
}
/** @param InputBag<bool|float|int|string> $inputBag */ /** @param InputBag<bool|float|int|string> $inputBag */
public function updateFromInputBag(InputBag $inputBag): self public function updateFromInputBag(InputBag $inputBag): self
{ {
@@ -55,10 +79,17 @@ 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;
} }
#[ORM\PrePersist]
public function setCreatedAtValue(): void
{
$this->created = new DateTimeImmutable();
}
public function getCreated(): \DateTimeInterface
{
return $this->created;
}
} }

View File

@@ -6,35 +6,67 @@ namespace Tvdt\Entity;
use Doctrine\DBAL\Types\Types; use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo; use Safe\DateTimeImmutable;
use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
use Symfony\Bridge\Doctrine\Types\UuidType; use Symfony\Bridge\Doctrine\Types\UuidType;
use Symfony\Component\Uid\Uuid; use Symfony\Component\Uid\Uuid;
use Tvdt\Repository\GivenAnswerRepository; use Tvdt\Repository\GivenAnswerRepository;
#[ORM\Entity(repositoryClass: GivenAnswerRepository::class)] #[ORM\Entity(repositoryClass: GivenAnswerRepository::class)]
#[ORM\HasLifecycleCallbacks]
class GivenAnswer class GivenAnswer
{ {
#[ORM\Column(type: UuidType::NAME, unique: true)] #[ORM\Column(type: UuidType::NAME, unique: true)]
#[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')] #[ORM\CustomIdGenerator(class: UuidGenerator::class)]
#[ORM\GeneratedValue(strategy: 'CUSTOM')] #[ORM\GeneratedValue(strategy: 'CUSTOM')]
#[ORM\Id] #[ORM\Id]
public private(set) Uuid $id; private Uuid $id;
#[Gedmo\Timestampable(on: 'create')]
#[ORM\Column(type: Types::DATETIMETZ_IMMUTABLE, nullable: false)] #[ORM\Column(type: Types::DATETIMETZ_IMMUTABLE, nullable: false)]
public private(set) \DateTimeImmutable $created; private \DateTimeImmutable $created;
public function __construct( public function __construct(
#[ORM\JoinColumn(nullable: false)] #[ORM\JoinColumn(nullable: false)]
#[ORM\ManyToOne(inversedBy: 'givenAnswers')] #[ORM\ManyToOne(inversedBy: 'givenAnswers')]
private(set) Candidate $candidate, private Candidate $candidate,
#[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')] #[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
#[ORM\ManyToOne] #[ORM\ManyToOne]
private(set) Quiz $quiz, private Quiz $quiz,
#[ORM\JoinColumn(nullable: false)] #[ORM\JoinColumn(nullable: false)]
#[ORM\ManyToOne(inversedBy: 'givenAnswers')] #[ORM\ManyToOne(inversedBy: 'givenAnswers')]
private(set) Answer $answer, private Answer $answer,
) {} ) {}
public function getId(): Uuid
{
return $this->id;
}
public function getCandidate(): Candidate
{
return $this->candidate;
}
public function getQuiz(): Quiz
{
return $this->quiz;
}
public function getAnswer(): Answer
{
return $this->answer;
}
public function getCreated(): \DateTimeImmutable
{
return $this->created;
}
#[ORM\PrePersist]
public function setCreatedAtValue(): void
{
$this->created = new DateTimeImmutable();
}
} }

View File

@@ -8,6 +8,7 @@ use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types; use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
use Symfony\Bridge\Doctrine\Types\UuidType; use Symfony\Bridge\Doctrine\Types\UuidType;
use Symfony\Component\Uid\Uuid; use Symfony\Component\Uid\Uuid;
use Tvdt\Repository\QuestionRepository; use Tvdt\Repository\QuestionRepository;
@@ -16,39 +17,86 @@ use Tvdt\Repository\QuestionRepository;
class Question class Question
{ {
#[ORM\Column(type: UuidType::NAME)] #[ORM\Column(type: UuidType::NAME)]
#[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')] #[ORM\CustomIdGenerator(class: UuidGenerator::class)]
#[ORM\GeneratedValue(strategy: 'CUSTOM')] #[ORM\GeneratedValue(strategy: 'CUSTOM')]
#[ORM\Id] #[ORM\Id]
public private(set) Uuid $id; private Uuid $id;
#[ORM\Column(type: Types::SMALLINT, options: ['default' => 0])] #[ORM\Column(type: Types::SMALLINT, options: ['default' => 0])]
public int $ordering; private int $ordering;
#[ORM\Column(type: Types::STRING, length: 255)] #[ORM\Column(type: Types::STRING, length: 255)]
public string $question; private string $question;
#[ORM\JoinColumn(nullable: false)] #[ORM\JoinColumn(nullable: false)]
#[ORM\ManyToOne(inversedBy: 'questions')] #[ORM\ManyToOne(inversedBy: 'questions')]
public Quiz $quiz; private Quiz $quiz;
#[ORM\Column] #[ORM\Column]
public bool $enabled = true; private bool $enabled = true;
/** @var Collection<int, Answer> */ /** @var Collection<int, Answer> */
#[ORM\OneToMany(targetEntity: Answer::class, mappedBy: 'question', cascade: ['persist'], orphanRemoval: true)] #[ORM\OneToMany(targetEntity: Answer::class, mappedBy: 'question', cascade: ['persist'], orphanRemoval: true)]
#[ORM\OrderBy(['ordering' => 'ASC'])] #[ORM\OrderBy(['ordering' => 'ASC'])]
public private(set) Collection $answers; private Collection $answers;
public function __construct() public function __construct()
{ {
$this->answers = new ArrayCollection(); $this->answers = new ArrayCollection();
} }
public function getId(): Uuid
{
return $this->id;
}
public function getQuestion(): string
{
return $this->question;
}
public function setQuestion(string $question): static
{
$this->question = $question;
return $this;
}
public function getQuiz(): Quiz
{
return $this->quiz;
}
public function setQuiz(Quiz $quiz): static
{
$this->quiz = $quiz;
return $this;
}
public function isEnabled(): ?bool
{
return $this->enabled;
}
public function setEnabled(bool $enabled): static
{
$this->enabled = $enabled;
return $this;
}
/** @return Collection<int, Answer> */
public function getAnswers(): Collection
{
return $this->answers;
}
public function addAnswer(Answer $answer): static public function addAnswer(Answer $answer): static
{ {
if (!$this->answers->contains($answer)) { if (!$this->answers->contains($answer)) {
$this->answers->add($answer); $this->answers->add($answer);
$answer->question = $this; $answer->setQuestion($this);
} }
return $this; return $this;
@@ -60,7 +108,7 @@ class Question
return 'This question has no answers'; return 'This question has no answers';
} }
$correctAnswers = $this->answers->filter(static fn (Answer $answer): bool => $answer->isRightAnswer)->count(); $correctAnswers = $this->answers->filter(static fn (Answer $answer): bool => $answer->isRightAnswer())->count();
if (0 === $correctAnswers) { if (0 === $correctAnswers) {
return 'This question has no correct answers'; return 'This question has no correct answers';
@@ -72,4 +120,16 @@ class Question
return null; return null;
} }
public function getOrdering(): int
{
return $this->ordering;
}
public function setOrdering(int $ordering): static
{
$this->ordering = $ordering;
return $this;
}
} }

View File

@@ -7,6 +7,7 @@ namespace Tvdt\Entity;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
use Symfony\Bridge\Doctrine\Types\UuidType; use Symfony\Bridge\Doctrine\Types\UuidType;
use Symfony\Component\Uid\Uuid; use Symfony\Component\Uid\Uuid;
use Tvdt\Repository\QuizRepository; use Tvdt\Repository\QuizRepository;
@@ -16,34 +17,34 @@ use Tvdt\Repository\QuizRepository;
class Quiz class Quiz
{ {
#[ORM\Column(type: UuidType::NAME)] #[ORM\Column(type: UuidType::NAME)]
#[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')] #[ORM\CustomIdGenerator(class: UuidGenerator::class)]
#[ORM\GeneratedValue(strategy: 'CUSTOM')] #[ORM\GeneratedValue(strategy: 'CUSTOM')]
#[ORM\Id] #[ORM\Id]
public private(set) Uuid $id; private Uuid $id;
#[ORM\Column(length: 64)] #[ORM\Column(length: 64)]
public string $name; private string $name;
#[ORM\JoinColumn(nullable: false)] #[ORM\JoinColumn(nullable: false)]
#[ORM\ManyToOne(inversedBy: 'quizzes')] #[ORM\ManyToOne(inversedBy: 'quizzes')]
public Season $season; private Season $season;
/** @var Collection<int, Question> */ /** @var Collection<int, Question> */
#[ORM\OneToMany(targetEntity: Question::class, mappedBy: 'quiz', cascade: ['persist'], orphanRemoval: true)] #[ORM\OneToMany(targetEntity: Question::class, mappedBy: 'quiz', cascade: ['persist'], orphanRemoval: true)]
#[ORM\OrderBy(['ordering' => 'ASC'])] #[ORM\OrderBy(['ordering' => 'ASC'])]
public private(set) Collection $questions; private Collection $questions;
/** @var Collection<int, QuizCandidate> */ /** @var Collection<int, QuizCandidate> */
#[ORM\OneToMany(targetEntity: QuizCandidate::class, mappedBy: 'quiz', orphanRemoval: true)] #[ORM\OneToMany(targetEntity: QuizCandidate::class, mappedBy: 'quiz', orphanRemoval: true)]
public private(set) Collection $candidateData; private Collection $candidateData;
#[ORM\Column(nullable: false, options: ['default' => 1])] #[ORM\Column(nullable: false, options: ['default' => 1])]
public int $dropouts = 1; private int $dropouts = 1;
/** @var Collection<int, Elimination> */ /** @var Collection<int, Elimination> */
#[ORM\OneToMany(targetEntity: Elimination::class, mappedBy: 'quiz', cascade: ['persist'], orphanRemoval: true)] #[ORM\OneToMany(targetEntity: Elimination::class, mappedBy: 'quiz', cascade: ['persist'], orphanRemoval: true)]
#[ORM\OrderBy(['created' => 'DESC'])] #[ORM\OrderBy(['created' => 'DESC'])]
public private(set) Collection $eliminations; private Collection $eliminations;
public function __construct() public function __construct()
{ {
@@ -52,16 +53,75 @@ class Quiz
$this->eliminations = new ArrayCollection(); $this->eliminations = new ArrayCollection();
} }
public function getId(): Uuid
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): static
{
$this->name = $name;
return $this;
}
public function getSeason(): Season
{
return $this->season;
}
public function setSeason(Season $season): static
{
$this->season = $season;
return $this;
}
/** @return Collection<int, Question> */
public function getQuestions(): Collection
{
return $this->questions;
}
public function addQuestion(Question $question): static public function addQuestion(Question $question): static
{ {
if (!$this->questions->contains($question)) { if (!$this->questions->contains($question)) {
$this->questions->add($question); $this->questions->add($question);
$question->quiz = $this; $question->setQuiz($this);
} }
return $this; return $this;
} }
/** @return Collection<int, QuizCandidate> */
public function getCandidateData(): Collection
{
return $this->candidateData;
}
public function getDropouts(): int
{
return $this->dropouts;
}
public function setDropouts(int $dropouts): static
{
$this->dropouts = $dropouts;
return $this;
}
/** @return Collection<int, Elimination> */
public function getEliminations(): Collection
{
return $this->eliminations;
}
public function addElimination(Elimination $elimination): self public function addElimination(Elimination $elimination): self
{ {
$this->eliminations->add($elimination); $this->eliminations->add($elimination);

View File

@@ -6,35 +6,74 @@ namespace Tvdt\Entity;
use Doctrine\DBAL\Types\Types; use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo; use Safe\DateTimeImmutable;
use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
use Symfony\Bridge\Doctrine\Types\UuidType; use Symfony\Bridge\Doctrine\Types\UuidType;
use Symfony\Component\Uid\Uuid; use Symfony\Component\Uid\Uuid;
use Tvdt\Repository\QuizCandidateRepository; use Tvdt\Repository\QuizCandidateRepository;
#[ORM\Entity(repositoryClass: QuizCandidateRepository::class)] #[ORM\Entity(repositoryClass: QuizCandidateRepository::class)]
#[ORM\HasLifecycleCallbacks]
#[ORM\UniqueConstraint(columns: ['candidate_id', 'quiz_id'])] #[ORM\UniqueConstraint(columns: ['candidate_id', 'quiz_id'])]
class QuizCandidate class QuizCandidate
{ {
#[ORM\Column(type: UuidType::NAME, unique: true)] #[ORM\Column(type: UuidType::NAME, unique: true)]
#[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')] #[ORM\CustomIdGenerator(class: UuidGenerator::class)]
#[ORM\GeneratedValue(strategy: 'CUSTOM')] #[ORM\GeneratedValue(strategy: 'CUSTOM')]
#[ORM\Id] #[ORM\Id]
public private(set) Uuid $id; private Uuid $id;
#[ORM\Column] #[ORM\Column]
public float $corrections = 0; private float $corrections = 0;
#[Gedmo\Timestampable(on: 'create')]
#[ORM\Column(type: Types::DATETIMETZ_IMMUTABLE)] #[ORM\Column(type: Types::DATETIMETZ_IMMUTABLE)]
public private(set) \DateTimeImmutable $created; private \DateTimeImmutable $created;
public function __construct( public function __construct(
#[ORM\JoinColumn(nullable: false)] #[ORM\JoinColumn(nullable: false)]
#[ORM\ManyToOne(inversedBy: 'candidateData')] #[ORM\ManyToOne(inversedBy: 'candidateData')]
public Quiz $quiz, private Quiz $quiz,
#[ORM\JoinColumn(nullable: false)] #[ORM\JoinColumn(nullable: false)]
#[ORM\ManyToOne(inversedBy: 'quizData')] #[ORM\ManyToOne(inversedBy: 'quizData')]
public Candidate $candidate, private Candidate $candidate,
) {} ) {}
public function getId(): Uuid
{
return $this->id;
}
public function getCandidate(): Candidate
{
return $this->candidate;
}
public function getQuiz(): Quiz
{
return $this->quiz;
}
public function getCorrections(): ?float
{
return $this->corrections;
}
public function setCorrections(float $corrections): static
{
$this->corrections = $corrections;
return $this;
}
public function getCreated(): \DateTimeImmutable
{
return $this->created;
}
#[ORM\PrePersist]
public function setCreatedAtValue(): void
{
$this->created = new DateTimeImmutable();
}
} }

View File

@@ -7,6 +7,7 @@ namespace Tvdt\Entity;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
use Symfony\Bridge\Doctrine\Types\UuidType; use Symfony\Bridge\Doctrine\Types\UuidType;
use Symfony\Component\Uid\Uuid; use Symfony\Component\Uid\Uuid;
use Tvdt\Repository\SeasonRepository; use Tvdt\Repository\SeasonRepository;
@@ -17,37 +18,37 @@ class Season
private const string SEASON_CODE_CHARACTERS = 'bcdfghjklmnpqrstvwxz'; private const string SEASON_CODE_CHARACTERS = 'bcdfghjklmnpqrstvwxz';
#[ORM\Column(type: UuidType::NAME)] #[ORM\Column(type: UuidType::NAME)]
#[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')] #[ORM\CustomIdGenerator(class: UuidGenerator::class)]
#[ORM\GeneratedValue(strategy: 'CUSTOM')] #[ORM\GeneratedValue(strategy: 'CUSTOM')]
#[ORM\Id] #[ORM\Id]
public private(set) Uuid $id; private Uuid $id;
#[ORM\Column(length: 64)] #[ORM\Column(length: 64)]
public string $name; private string $name;
#[ORM\Column(length: 5)] #[ORM\Column(length: 5)]
public string $seasonCode; private string $seasonCode;
/** @var Collection<int, Quiz> */ /** @var Collection<int, Quiz> */
#[ORM\OneToMany(targetEntity: Quiz::class, mappedBy: 'season', cascade: ['persist'], orphanRemoval: true)] #[ORM\OneToMany(targetEntity: Quiz::class, mappedBy: 'season', cascade: ['persist'], orphanRemoval: true)]
public private(set) Collection $quizzes; private Collection $quizzes;
/** @var Collection<int, Candidate> */ /** @var Collection<int, Candidate> */
#[ORM\OneToMany(targetEntity: Candidate::class, mappedBy: 'season', cascade: ['persist'], orphanRemoval: true)] #[ORM\OneToMany(targetEntity: Candidate::class, mappedBy: 'season', cascade: ['persist'], orphanRemoval: true)]
#[ORM\OrderBy(['name' => 'ASC'])] #[ORM\OrderBy(['name' => 'ASC'])]
public private(set) Collection $candidates; private Collection $candidates;
/** @var Collection<int, User> */ /** @var Collection<int, User> */
#[ORM\ManyToMany(targetEntity: User::class, inversedBy: 'seasons')] #[ORM\ManyToMany(targetEntity: User::class, inversedBy: 'seasons')]
public private(set) Collection $owners; private Collection $owners;
#[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')] #[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')]
#[ORM\ManyToOne] #[ORM\ManyToOne]
public ?Quiz $activeQuiz = null; private ?Quiz $ActiveQuiz = null;
#[ORM\JoinColumn(nullable: true)] #[ORM\JoinColumn(nullable: true)]
#[ORM\OneToOne(cascade: ['persist', 'remove'])] #[ORM\OneToOne(cascade: ['persist', 'remove'])]
public ?SeasonSettings $settings = null; private ?SeasonSettings $settings = null;
public function __construct() public function __construct()
{ {
@@ -57,26 +58,73 @@ class Season
$this->owners = new ArrayCollection(); $this->owners = new ArrayCollection();
} }
public function getId(): Uuid
{
return $this->id;
}
public function getName(): string
{
return $this->name;
}
public function setName(string $name): static
{
$this->name = $name;
return $this;
}
public function getSeasonCode(): ?string
{
return $this->seasonCode;
}
public function setSeasonCode(string $seasonCode): static
{
$this->seasonCode = $seasonCode;
return $this;
}
/** @return Collection<int, Quiz> */
public function getQuizzes(): Collection
{
return $this->quizzes;
}
public function addQuiz(Quiz $quiz): static public function addQuiz(Quiz $quiz): static
{ {
if (!$this->quizzes->contains($quiz)) { if (!$this->quizzes->contains($quiz)) {
$this->quizzes->add($quiz); $this->quizzes->add($quiz);
$quiz->season = $this; $quiz->setSeason($this);
} }
return $this; return $this;
} }
/** @return Collection<int, Candidate> */
public function getCandidates(): Collection
{
return $this->candidates;
}
public function addCandidate(Candidate $candidate): static public function addCandidate(Candidate $candidate): static
{ {
if (!$this->candidates->contains($candidate)) { if (!$this->candidates->contains($candidate)) {
$this->candidates->add($candidate); $this->candidates->add($candidate);
$candidate->season = $this; $candidate->setSeason($this);
} }
return $this; return $this;
} }
/** @return Collection<int, User> */
public function getOwners(): Collection
{
return $this->owners;
}
public function addOwner(User $owner): static public function addOwner(User $owner): static
{ {
if (!$this->owners->contains($owner)) { if (!$this->owners->contains($owner)) {
@@ -93,12 +141,24 @@ class Season
return $this; return $this;
} }
public function getActiveQuiz(): ?Quiz
{
return $this->ActiveQuiz;
}
public function setActiveQuiz(?Quiz $ActiveQuiz): static
{
$this->ActiveQuiz = $ActiveQuiz;
return $this;
}
public function isOwner(User $user): bool public function isOwner(User $user): bool
{ {
return $this->owners->contains($user); return $this->owners->contains($user);
} }
public function generateSeasonCode(): void public function generateSeasonCode(): self
{ {
$code = ''; $code = '';
$len = mb_strlen(self::SEASON_CODE_CHARACTERS) - 1; $len = mb_strlen(self::SEASON_CODE_CHARACTERS) - 1;
@@ -108,5 +168,19 @@ class Season
} }
$this->seasonCode = $code; $this->seasonCode = $code;
return $this;
}
public function getSettings(): ?SeasonSettings
{
return $this->settings;
}
public function setSettings(SeasonSettings $settings): static
{
$this->settings = $settings;
return $this;
} }
} }

View File

@@ -6,6 +6,7 @@ namespace Tvdt\Entity;
use Doctrine\DBAL\Types\Types; use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
use Symfony\Bridge\Doctrine\Types\UuidType; use Symfony\Bridge\Doctrine\Types\UuidType;
use Symfony\Component\Uid\Uuid; use Symfony\Component\Uid\Uuid;
use Tvdt\Repository\SeasonSettingsRepository; use Tvdt\Repository\SeasonSettingsRepository;
@@ -14,14 +15,43 @@ use Tvdt\Repository\SeasonSettingsRepository;
class SeasonSettings class SeasonSettings
{ {
#[ORM\Column(type: UuidType::NAME)] #[ORM\Column(type: UuidType::NAME)]
#[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')] #[ORM\CustomIdGenerator(class: UuidGenerator::class)]
#[ORM\GeneratedValue(strategy: 'CUSTOM')] #[ORM\GeneratedValue(strategy: 'CUSTOM')]
#[ORM\Id] #[ORM\Id]
public private(set) Uuid $id; private Uuid $id;
#[ORM\Column(type: Types::BOOLEAN, options: ['default' => false])] #[ORM\Column(type: Types::BOOLEAN, options: ['default' => false])]
public bool $showNumbers = false; private bool $showNumbers = false;
#[ORM\Column(type: Types::BOOLEAN, options: ['default' => false])] #[ORM\Column(type: Types::BOOLEAN, options: ['default' => false])]
public bool $confirmAnswers = false; private bool $confirmAnswers = false;
public function getId(): Uuid
{
return $this->id;
}
public function isShowNumbers(): bool
{
return $this->showNumbers;
}
public function setShowNumbers(bool $showNumbers): self
{
$this->showNumbers = $showNumbers;
return $this;
}
public function isConfirmAnswers(): bool
{
return $this->confirmAnswers;
}
public function setConfirmAnswers(bool $confirmAnswers): self
{
$this->confirmAnswers = $confirmAnswers;
return $this;
}
} }

View File

@@ -8,6 +8,7 @@ use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types; use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
use Symfony\Bridge\Doctrine\Types\UuidType; use Symfony\Bridge\Doctrine\Types\UuidType;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface; use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
@@ -22,38 +23,51 @@ use Tvdt\Repository\UserRepository;
class User implements UserInterface, PasswordAuthenticatedUserInterface class User implements UserInterface, PasswordAuthenticatedUserInterface
{ {
#[ORM\Column(type: UuidType::NAME, unique: true)] #[ORM\Column(type: UuidType::NAME, unique: true)]
#[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')] #[ORM\CustomIdGenerator(class: UuidGenerator::class)]
#[ORM\GeneratedValue(strategy: 'CUSTOM')] #[ORM\GeneratedValue(strategy: 'CUSTOM')]
#[ORM\Id] #[ORM\Id]
public private(set) Uuid $id; private Uuid $id;
#[ORM\Column(length: 180)] #[ORM\Column(length: 180)]
public string $email; private string $email;
/** @var list<string> The user roles */ /** @var list<string> The user roles */
#[ORM\Column(type: Types::JSON)] #[ORM\Column(type: Types::JSON)]
public array $roles = []; private array $roles = [];
/** @var string The hashed password */ /** @var string The hashed password */
#[ORM\Column] #[ORM\Column]
public string $password; private string $password;
/** @var Collection<int, Season> */ /** @var Collection<int, Season> */
#[ORM\ManyToMany(targetEntity: Season::class, mappedBy: 'owners')] #[ORM\ManyToMany(targetEntity: Season::class, mappedBy: 'owners')]
public private(set) Collection $seasons; private Collection $seasons;
#[ORM\Column] #[ORM\Column]
public bool $isVerified = false; private bool $isVerified = false;
public bool $isAdmin {
get => \in_array('ROLE_ADMIN', $this->getRoles(), true);
}
public function __construct() public function __construct()
{ {
$this->seasons = new ArrayCollection(); $this->seasons = new ArrayCollection();
} }
public function getId(): Uuid
{
return $this->id;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): static
{
$this->email = $email;
return $this;
}
/** /**
* A visual identifier that represents this user. * A visual identifier that represents this user.
* *
@@ -83,12 +97,27 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
return array_unique($roles); return array_unique($roles);
} }
/** @param list<string> $roles */
public function setRoles(array $roles): static
{
$this->roles = $roles;
return $this;
}
/** @see PasswordAuthenticatedUserInterface */ /** @see PasswordAuthenticatedUserInterface */
public function getPassword(): ?string public function getPassword(): ?string
{ {
return $this->password; return $this->password;
} }
public function setPassword(string $password): static
{
$this->password = $password;
return $this;
}
/** @see UserInterface */ /** @see UserInterface */
public function eraseCredentials(): void public function eraseCredentials(): void
{ {
@@ -96,6 +125,12 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
// $this->plainPassword = null; // $this->plainPassword = null;
} }
/** @return Collection<int, Season> */
public function getSeasons(): Collection
{
return $this->seasons;
}
public function addSeason(Season $season): static public function addSeason(Season $season): static
{ {
if (!$this->seasons->contains($season)) { if (!$this->seasons->contains($season)) {
@@ -114,4 +149,21 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
return $this; return $this;
} }
public function isVerified(): bool
{
return $this->isVerified;
}
public function setIsVerified(bool $isVerified): static
{
$this->isVerified = $isVerified;
return $this;
}
public function isAdmin(): bool
{
return \in_array('ROLE_ADMIN', $this->getRoles(), true);
}
} }

View File

@@ -7,18 +7,11 @@ 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

@@ -7,12 +7,12 @@ namespace Tvdt\Factory;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Tvdt\Entity\Elimination; use Tvdt\Entity\Elimination;
use Tvdt\Entity\Quiz; use Tvdt\Entity\Quiz;
use Tvdt\Repository\QuizRepository; use Tvdt\Repository\CandidateRepository;
final readonly class EliminationFactory final readonly class EliminationFactory
{ {
public function __construct( public function __construct(
private QuizRepository $quizRepository, private CandidateRepository $candidateRepository,
private EntityManagerInterface $em, private EntityManagerInterface $em,
) {} ) {}
@@ -21,15 +21,15 @@ final readonly class EliminationFactory
$elimination = new Elimination($quiz); $elimination = new Elimination($quiz);
$this->em->persist($elimination); $this->em->persist($elimination);
$scores = $this->quizRepository->getScores($quiz); $scores = $this->candidateRepository->getScores($quiz);
$simpleScores = []; $simpleScores = [];
foreach (array_reverse($scores) as $i => $score) { foreach (array_reverse($scores) as $i => $score) {
$simpleScores[$score->name] = $i < $quiz->dropouts ? Elimination::SCREEN_RED : Elimination::SCREEN_GREEN; $simpleScores[$score['name']] = $i < $quiz->getDropouts() ? Elimination::SCREEN_RED : Elimination::SCREEN_GREEN;
} }
$elimination->data = $simpleScores; $elimination->setData($simpleScores);
$this->em->flush(); $this->em->flush();

View File

@@ -7,12 +7,17 @@ namespace Tvdt\Repository;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry; use Doctrine\Persistence\ManagerRegistry;
use Safe\Exceptions\UrlException; use Safe\Exceptions\UrlException;
use Symfony\Component\Uid\Uuid;
use Tvdt\Entity\Candidate; use Tvdt\Entity\Candidate;
use Tvdt\Entity\Quiz;
use Tvdt\Entity\Season; use Tvdt\Entity\Season;
use Tvdt\Helpers\Base64; use Tvdt\Helpers\Base64;
/** /**
* @extends ServiceEntityRepository<Candidate> * @extends ServiceEntityRepository<Candidate>
*
* @phpstan-type Result array{id: Uuid, name: string, correct: int, time: \DateInterval, corrections: float, score: float}
* @phpstan-type ResultList list<Result>
*/ */
class CandidateRepository extends ServiceEntityRepository class CandidateRepository extends ServiceEntityRepository
{ {
@@ -38,4 +43,35 @@ class CandidateRepository extends ServiceEntityRepository
->setParameter('name', $name) ->setParameter('name', $name)
->getOneOrNullResult(); ->getOneOrNullResult();
} }
public function save(Candidate $candidate, bool $flush = true): void
{
$this->getEntityManager()->persist($candidate);
if ($flush) {
$this->getEntityManager()->flush();
}
}
/** @return ResultList */
public function getScores(Quiz $quiz): array
{
return $this->getEntityManager()->createQuery(<<<DQL
select
c.id,
c.name,
count(case when a.isRightAnswer = true then 1 else null end) as correct,
qc.corrections,
max(ga.created) - qc.created as time,
(count(case when a.isRightAnswer = true then 1 else null end) + qc.corrections) as score
from Tvdt\Entity\Candidate c
join c.givenAnswers ga
join ga.answer a
join c.quizData qc
where qc.quiz = :quiz and ga.quiz = :quiz
group by ga.quiz, c.id, qc.id
order by score desc, time asc
DQL
)->setParameter('quiz', $quiz)->getResult();
}
} }

View File

@@ -17,4 +17,13 @@ class GivenAnswerRepository extends ServiceEntityRepository
{ {
parent::__construct($registry, GivenAnswer::class); parent::__construct($registry, GivenAnswer::class);
} }
public function save(GivenAnswer $givenAnswer, bool $flush = true): void
{
$this->getEntityManager()->persist($givenAnswer);
if ($flush) {
$this->getEntityManager()->flush();
}
}
} }

View File

@@ -35,7 +35,7 @@ class QuestionRepository extends ServiceEntityRepository
DQL) DQL)
->setMaxResults(1) ->setMaxResults(1)
->setParameter('candidate', $candidate) ->setParameter('candidate', $candidate)
->setParameter('quiz', $candidate->season->activeQuiz) ->setParameter('quiz', $candidate->getSeason()->getActiveQuiz())
->getOneOrNullResult(); ->getOneOrNullResult();
} }
} }

View File

@@ -41,7 +41,7 @@ class QuizCandidateRepository extends ServiceEntityRepository
throw new \InvalidArgumentException('Quiz candidate not found'); throw new \InvalidArgumentException('Quiz candidate not found');
} }
$quizCandidate->corrections = $corrections; $quizCandidate->setCorrections($corrections);
$this->getEntityManager()->flush(); $this->getEntityManager()->flush();
} }
} }

View File

@@ -7,10 +7,10 @@ namespace Tvdt\Repository;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry; use Doctrine\Persistence\ManagerRegistry;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use Safe\DateTimeImmutable; use Tvdt\Entity\Elimination;
use Safe\Exceptions\DatetimeException; use Tvdt\Entity\GivenAnswer;
use Tvdt\Dto\Result;
use Tvdt\Entity\Quiz; use Tvdt\Entity\Quiz;
use Tvdt\Entity\QuizCandidate;
use Tvdt\Exception\ErrorClearingQuizException; use Tvdt\Exception\ErrorClearingQuizException;
/** /**
@@ -29,36 +29,28 @@ class QuizRepository extends ServiceEntityRepository
$em = $this->getEntityManager(); $em = $this->getEntityManager();
$em->beginTransaction(); $em->beginTransaction();
try { try {
$em->createQuery(<<<DQL $em->createQueryBuilder()
delete from Tvdt\Entity\QuizCandidate qc ->delete()->from(QuizCandidate::class, 'qc')
where qc.quiz = :quiz ->where('qc.quiz = :quiz')
DQL)
->setParameter('quiz', $quiz) ->setParameter('quiz', $quiz)
->execute(); ->getQuery()->execute();
$em->createQuery(<<<DQL $em->createQueryBuilder()
delete from Tvdt\Entity\GivenAnswer ga ->delete()->from(GivenAnswer::class, 'ga')
where ga.quiz = :quiz ->where('ga.quiz = :quiz')
DQL)
->setParameter('quiz', $quiz) ->setParameter('quiz', $quiz)
->execute(); ->getQuery()->execute();
$em->createQueryBuilder()
$em->createQuery(<<<DQL ->delete()->from(Elimination::class, 'e')
delete from Tvdt\Entity\Elimination e ->where('e.quiz = :quiz')
where e.quiz = :quiz
DQL)
->setParameter('quiz', $quiz) ->setParameter('quiz', $quiz)
->execute(); ->getQuery()->execute();
} } catch (\Throwable $throwable) {
// @codeCoverageIgnoreStart
catch (\Throwable $throwable) {
$this->logger->error($throwable->getMessage()); $this->logger->error($throwable->getMessage());
$em->rollback(); $em->rollback();
throw new ErrorClearingQuizException(previous: $throwable); throw new ErrorClearingQuizException(previous: $throwable);
} }
// @codeCoverageIgnoreEnd
$em->commit(); $em->commit();
} }
@@ -67,40 +59,4 @@ class QuizRepository extends ServiceEntityRepository
$this->getEntityManager()->remove($quiz); $this->getEntityManager()->remove($quiz);
$this->getEntityManager()->flush(); $this->getEntityManager()->flush();
} }
/**
* @throws DatetimeException
*
* @return list<Result>
*/
public function getScores(Quiz $quiz): array
{
$result = $this->getEntityManager()->createQuery(<<<DQL
select
c.id,
c.name,
sum(case when a.isRightAnswer = true then 1 else 0 end) as correct,
qd.corrections,
max(ga.created) as end_time,
qd.created as start_time,
(sum(case when a.isRightAnswer = true then 1 else 0 end) + qd.corrections) as score
from Tvdt\Entity\Candidate c
join c.givenAnswers ga
join ga.answer a
join c.quizData qd
where qd.quiz = :quiz and ga.quiz = :quiz
group by ga.quiz, c.id, qd.id
order by score desc, max(ga.created) - qd.created asc
DQL
)->setParameter('quiz', $quiz)->getResult();
return array_map(static fn (array $row): Result => new Result(
id: $row['id'],
name: $row['name'],
correct: (int) $row['correct'],
corrections: $row['corrections'],
time: $row['start_time']->diff(new DateTimeImmutable($row['end_time'])),
score: $row['score'],
), $result);
}
} }

View File

@@ -19,17 +19,6 @@ class SeasonRepository extends ServiceEntityRepository
parent::__construct($registry, Season::class); parent::__construct($registry, Season::class);
} }
public function findOneBySeasonCode(string $seasonCode): ?Season
{
return $this->getEntityManager()->createQuery(<<<DQL
select s from Tvdt\Entity\Season s
where s.seasonCode = :seasonCode
DQL)
->setParameter('seasonCode', $seasonCode)
->setMaxResults(1)
->getOneOrNullResult();
}
/** @return list<Season> Returns an array of Season objects */ /** @return list<Season> Returns an array of Season objects */
public function getSeasonsForUser(User $user): array public function getSeasonsForUser(User $user): array
{ {

View File

@@ -23,7 +23,7 @@ class UserRepository extends ServiceEntityRepository implements PasswordUpgrader
* */ * */
public function upgradePassword(PasswordAuthenticatedUserInterface $user, string $newHashedPassword): void public function upgradePassword(PasswordAuthenticatedUserInterface $user, string $newHashedPassword): void
{ {
$user->password = $newHashedPassword; $user->setPassword($newHashedPassword);
$this->getEntityManager()->persist($user); $this->getEntityManager()->persist($user);
$this->getEntityManager()->flush(); $this->getEntityManager()->flush();
} }
@@ -35,7 +35,7 @@ class UserRepository extends ServiceEntityRepository implements PasswordUpgrader
throw new \InvalidArgumentException('User not found'); throw new \InvalidArgumentException('User not found');
} }
$user->roles = ['ROLE_ADMIN']; $user->setRoles(['ROLE_ADMIN']);
$this->getEntityManager()->flush(); $this->getEntityManager()->flush();
} }
} }

View File

@@ -25,9 +25,9 @@ readonly class EmailVerifier
{ {
$signatureComponents = $this->verifyEmailHelper->generateSignature( $signatureComponents = $this->verifyEmailHelper->generateSignature(
$verifyEmailRouteName, $verifyEmailRouteName,
$user->id->toRfc4122(), (string) $user->getId(),
$user->email, (string) $user->getEmail(),
['id' => $user->id], ['id' => $user->getId()],
); );
$context = $email->getContext(); $context = $email->getContext();
@@ -42,9 +42,9 @@ readonly class EmailVerifier
public function handleEmailConfirmation(Request $request, User $user): void public function handleEmailConfirmation(Request $request, User $user): void
{ {
$this->verifyEmailHelper->validateEmailConfirmationFromRequest($request, $user->id->toRfc4122(), $user->email); $this->verifyEmailHelper->validateEmailConfirmationFromRequest($request, (string) $user->getId(), (string) $user->getEmail());
$user->isVerified = true; $user->setIsVerified(true);
$this->entityManager->persist($user); $this->entityManager->persist($user);
$this->entityManager->flush(); $this->entityManager->flush();

View File

@@ -15,7 +15,7 @@ use Tvdt\Entity\Quiz;
use Tvdt\Entity\Season; use Tvdt\Entity\Season;
use Tvdt\Entity\User; use Tvdt\Entity\User;
/** @extends Voter<string, Season|Elimination|Quiz|Candidate|Answer|Question> */ /** @extends Voter<string, Season> */
final class SeasonVoter extends Voter final class SeasonVoter extends Voter
{ {
public const string EDIT = 'SEASON_EDIT'; public const string EDIT = 'SEASON_EDIT';
@@ -28,15 +28,16 @@ final class SeasonVoter extends Voter
{ {
return \in_array($attribute, [self::EDIT, self::DELETE, self::ELIMINATION], true) return \in_array($attribute, [self::EDIT, self::DELETE, self::ELIMINATION], true)
&& ( && (
$subject instanceof Answer $subject instanceof Season
|| $subject instanceof Candidate
|| $subject instanceof Elimination || $subject instanceof Elimination
|| $subject instanceof Season
|| $subject instanceof Question
|| $subject instanceof Quiz || $subject instanceof Quiz
|| $subject instanceof Candidate
|| $subject instanceof Answer
|| $subject instanceof Question
); );
} }
/** @param Season|Elimination|Quiz|Candidate|Answer|Question $subject */
protected function voteOnAttribute(string $attribute, mixed $subject, TokenInterface $token, ?Vote $vote = null): bool protected function voteOnAttribute(string $attribute, mixed $subject, TokenInterface $token, ?Vote $vote = null): bool
{ {
$user = $token->getUser(); $user = $token->getUser();
@@ -44,18 +45,28 @@ final class SeasonVoter extends Voter
return false; return false;
} }
if ($user->isAdmin) { if ($user->isAdmin()) {
return true; return true;
} }
$season = match (true) { switch (true) {
$subject instanceof Answer => $subject->question->quiz->season, case $subject instanceof Answer:
$subject instanceof Elimination, $season = $subject->getQuestion()->getQuiz()->getSeason();
$subject instanceof Question => $subject->quiz->season, break;
$subject instanceof Candidate, case $subject instanceof Elimination:
$subject instanceof Quiz => $subject->season, case $subject instanceof Question:
$subject instanceof Season => $subject, $season = $subject->getQuiz()->getSeason();
}; break;
case $subject instanceof Candidate:
case $subject instanceof Quiz:
$season = $subject->getSeason();
break;
case $subject instanceof Season:
$season = $subject;
break;
default:
return false;
}
return match ($attribute) { return match ($attribute) {
self::EDIT, self::DELETE, self::ELIMINATION => $season->isOwner($user), self::EDIT, self::DELETE, self::ELIMINATION => $season->isOwner($user),

View File

@@ -0,0 +1,16 @@
<?php
declare(strict_types=1);
namespace Tvdt\Service;
use Tvdt\Repository\CandidateRepository;
/**
* @phpstan-import-type ResultList from CandidateRepository
*/
class EliminationService
{
/** @phpstan-param ResultList $result */
public function createEliminationFromResult(array $result): void {}
}

View File

@@ -55,10 +55,6 @@ class QuizSpreadsheetService
/** @throws SpreadsheetDataException */ /** @throws SpreadsheetDataException */
public function xlsxToQuiz(Quiz $quiz, File $file): void public function xlsxToQuiz(Quiz $quiz, File $file): void
{ {
if (!$this->isSpreadsheetFile($file)) {
throw new \InvalidArgumentException('File must be a valid XLSX spreadsheet');
}
$spreadsheet = $this->readSheet($file); $spreadsheet = $this->readSheet($file);
$sheet = $spreadsheet->getSheet($spreadsheet->getFirstSheetIndex()); $sheet = $spreadsheet->getSheet($spreadsheet->getFirstSheetIndex());
@@ -88,8 +84,8 @@ class QuizSpreadsheetService
} }
$question = new Question(); $question = new Question();
$question->question = (string) $questionArr[0]; $question->setQuestion((string) $questionArr[0]);
$question->ordering = $questionCounter++; $question->setOrdering($questionCounter++);
$answerCounter = 1; $answerCounter = 1;
$arrCounter = 1; $arrCounter = 1;
@@ -104,7 +100,7 @@ class QuizSpreadsheetService
} }
$answer = new Answer((string) $questionArr[$arrCounter++], (bool) $questionArr[$arrCounter++]); $answer = new Answer((string) $questionArr[$arrCounter++], (bool) $questionArr[$arrCounter++]);
$answer->ordering = $answerCounter++; $answer->setOrdering($answerCounter++);
$question->addAnswer($answer); $question->addAnswer($answer);
} }
@@ -116,10 +112,7 @@ class QuizSpreadsheetService
} }
} }
public function quizToXlsx(Quiz $quiz): void public function quizToXlsx(Quiz $quiz): void {}
{
throw new \Exception('Not implemented');
}
private function toXlsx(Spreadsheet $spreadsheet): \Closure private function toXlsx(Spreadsheet $spreadsheet): \Closure
{ {
@@ -127,9 +120,4 @@ class QuizSpreadsheetService
return static fn () => $writer->save('php://output'); return static fn () => $writer->save('php://output');
} }
private function isSpreadsheetFile(File $file): bool
{
return 'xlsx' === $file->getExtension();
}
} }

View File

@@ -1,16 +1,4 @@
{ {
"dama/doctrine-test-bundle": {
"version": "8.4",
"recipe": {
"repo": "github.com/symfony/recipes-contrib",
"branch": "main",
"version": "8.3",
"ref": "dfc51177476fb39d014ed89944cde53dc3326d23"
},
"files": [
"config/packages/dama_doctrine_test_bundle.yaml"
]
},
"doctrine/deprecations": { "doctrine/deprecations": {
"version": "1.1", "version": "1.1",
"recipe": { "recipe": {
@@ -84,44 +72,31 @@
] ]
}, },
"phpunit/phpunit": { "phpunit/phpunit": {
"version": "12.4", "version": "12.1",
"recipe": { "recipe": {
"repo": "github.com/symfony/recipes", "repo": "github.com/symfony/recipes",
"branch": "main", "branch": "main",
"version": "11.1", "version": "10.0",
"ref": "1117deb12541f35793eec9fff7494d7aa12283fc" "ref": "bb22cf8d8c554a623b427d5f3416b538f5525233"
}, },
"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.6", "version": "5.2",
"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": "b6cb4b34429dadecd7187852123be19d628fa37a" "ref": "c3decefe8a11a5da43adaf827a6cd66695586113"
}, },
"files": [ "files": [
"config/packages/sentry.yaml" "config/packages/sentry.yaml"
] ]
}, },
"stof/doctrine-extensions-bundle": {
"version": "1.14",
"recipe": {
"repo": "github.com/symfony/recipes-contrib",
"branch": "main",
"version": "1.2",
"ref": "e805aba9eff5372e2d149a9ff56566769e22819d"
},
"files": [
"config/packages/stof_doctrine_extensions.yaml"
]
},
"symfony/asset-mapper": { "symfony/asset-mapper": {
"version": "7.2", "version": "7.2",
"recipe": { "recipe": {

View File

@@ -109,7 +109,7 @@
</form> </form>
</td> </td>
<td>{{ candidate.score|default('x') }}</td> <td>{{ candidate.score|default('x') }}</td>
<td>{{ candidate.time.format('%i:%S') }}</td> <td>{{ candidate.time }}</td>
</tr> </tr>
{% else %} {% else %}
<tr> <tr>

View File

@@ -1,70 +0,0 @@
<?php
declare(strict_types=1);
namespace Tvdt\Tests\Command;
use PHPUnit\Framework\Attributes\CoversClass;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Tester\CommandTester;
use Symfony\Component\HttpKernel\KernelInterface;
use Tvdt\Command\ClaimSeasonCommand;
use Tvdt\Entity\Season;
use Tvdt\Repository\SeasonRepository;
#[CoversClass(ClaimSeasonCommand::class)]
final class ClaimSeasonCommandTest extends KernelTestCase
{
private SeasonRepository $seasonRepository;
private CommandTester $commandTester;
protected function setUp(): void
{
$container = self::getContainer();
$this->assertInstanceOf(KernelInterface::class, self::$kernel);
$this->seasonRepository = $container->get(SeasonRepository::class);
$application = new Application(self::$kernel);
$command = $application->find('tvdt:claim-season');
$this->commandTester = new CommandTester($command);
}
public function testSeasonClaim(): void
{
$this->commandTester->execute([
'season-code' => 'krtek',
'email' => 'test@example.org',
]);
$season = $this->seasonRepository->findOneBySeasonCode('krtek');
$this->assertInstanceOf(Season::class, $season);
$this->assertSame(Command::SUCCESS, $this->commandTester->getStatusCode());
$this->assertCount(3, $season->owners);
}
public function testInvalidEmailFails(): void
{
$this->commandTester->execute([
'season-code' => 'krtek',
'email' => 'nonexisting@example.org',
]);
$this->assertSame(Command::FAILURE, $this->commandTester->getStatusCode());
}
public function testInvalidSeasonCodeFails(): void
{
$this->commandTester->execute([
'season-code' => 'dhadk',
'email' => 'test@example.org',
]);
$this->assertSame(Command::FAILURE, $this->commandTester->getStatusCode());
}
}

View File

@@ -1,57 +0,0 @@
<?php
declare(strict_types=1);
namespace Tvdt\Tests\Command;
use PHPUnit\Framework\Attributes\CoversClass;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Tester\CommandTester;
use Symfony\Component\HttpKernel\KernelInterface;
use Tvdt\Command\MakeAdminCommand;
use Tvdt\Entity\User;
use Tvdt\Repository\UserRepository;
#[CoversClass(MakeAdminCommand::class)]
final class MakeAdminCommandTest extends KernelTestCase
{
private UserRepository $userRepository;
private CommandTester $commandTester;
protected function setUp(): void
{
$container = self::getContainer();
$this->assertInstanceOf(KernelInterface::class, self::$kernel);
$this->userRepository = $container->get(UserRepository::class);
$application = new Application(self::$kernel);
$command = $application->find('tvdt:make-admin');
$this->commandTester = new CommandTester($command);
}
public function testMakeAdmin(): void
{
$this->commandTester->execute([
'email' => 'test@example.org',
]);
$user = $this->userRepository->findOneBy(['email' => 'test@example.org']);
$this->assertInstanceOf(User::class, $user);
$this->assertSame(Command::SUCCESS, $this->commandTester->getStatusCode());
$this->assertContains('ROLE_ADMIN', $user->roles);
}
public function testInvalidEmailFails(): void
{
$this->commandTester->execute([
'email' => 'nonexisting@example.org',
]);
$this->assertSame(Command::FAILURE, $this->commandTester->getStatusCode());
}
}

View File

@@ -1,41 +0,0 @@
<?php
declare(strict_types=1);
namespace Tvdt\Tests\Helpers;
use PHPUnit\Framework\TestCase;
use Safe\Exceptions\UrlException;
use Tvdt\Helpers\Base64;
final class Base64Test extends TestCase
{
public function testBase64UrlEncode(): void
{
$this->assertSame('TWFyaWpu', Base64::base64UrlEncode('Marijn'));
$this->assertSame('UGhpbGluZQ', Base64::base64UrlEncode('Philine'));
$this->assertSame('_g', Base64::base64UrlEncode(\chr(254)));
$this->assertSame('-g', Base64::base64UrlEncode(\chr(250)));
}
public function testBase64UrlDecode(): void
{
$this->assertSame('Marijn', Base64::base64UrlDecode('TWFyaWpu'));
$this->assertSame('Philine', Base64::base64UrlDecode('UGhpbGluZQ'));
$this->assertSame(\chr(254), Base64::base64UrlDecode('_g'));
$this->assertSame(\chr(250), Base64::base64UrlDecode('-g'));
}
public function testBase64UrlDecodeCanHandlePadding(): void
{
$this->assertSame('Philine', Base64::base64UrlDecode('UGhpbGluZQ=='));
}
public function testBase64UrlDecodeThrowsExceptionOnInvalidInput(): void
{
$this->expectException(UrlException::class);
Base64::base64UrlDecode('Philine==');
}
}

View File

@@ -1,56 +0,0 @@
<?php
declare(strict_types=1);
namespace Tvdt\Tests\Repository;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use Tvdt\Entity\Candidate;
use Tvdt\Repository\CandidateRepository;
#[CoversClass(CandidateRepository::class)]
final class CandidateRepositoryTest extends DatabaseTestCase
{
/** @return iterable<string, array{0: string}> */
public static function candidateHashDataProvider(): iterable
{
yield 'Normal' => ['Q2xhdWRpYQ'];
yield 'lowercase' => ['Y2xhdWRpYQ'];
yield 'UPPERCASE' => ['Q0xBVURJQQ'];
}
#[DataProvider('candidateHashDataProvider')]
public function testGetCandidateByHash(string $hash): void
{
$krtekSeason = $this->getSeasonByCode('krtek');
$candidate = $this->candidateRepository->getCandidateByHash(
$krtekSeason,
$hash,
);
$this->assertInstanceOf(Candidate::class, $candidate);
$this->assertSame('Claudia', $candidate->name);
}
public function testGetCandidateByHashUnknownHashReturnsNull(): void
{
$krtekSeason = $this->getSeasonByCode('krtek');
$result = $this->candidateRepository->getCandidateByHash(
$krtekSeason,
'TWFyaWpu',
);
$this->assertNotInstanceOf(Candidate::class, $result);
}
public function testGetCandidateByHashInvalidBase64HashReturnsNull(): void
{
$krtekSeason = $this->getSeasonByCode('krtek');
$result = $this->candidateRepository->getCandidateByHash(
$krtekSeason,
'TWFyaWpu*',
);
$this->assertNotInstanceOf(Candidate::class, $result);
}
}

View File

@@ -1,70 +0,0 @@
<?php
declare(strict_types=1);
namespace Tvdt\Tests\Repository;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Tvdt\Entity\Candidate;
use Tvdt\Entity\Season;
use Tvdt\Entity\User;
use Tvdt\Repository\CandidateRepository;
use Tvdt\Repository\QuestionRepository;
use Tvdt\Repository\QuizCandidateRepository;
use Tvdt\Repository\QuizRepository;
use Tvdt\Repository\SeasonRepository;
use Tvdt\Repository\UserRepository;
abstract class DatabaseTestCase extends KernelTestCase
{
protected private(set) EntityManagerInterface $entityManager;
protected private(set) CandidateRepository $candidateRepository;
protected private(set) QuestionRepository $questionRepository;
protected private(set) QuizCandidateRepository $quizCandidateRepository;
protected private(set) QuizRepository $quizRepository;
protected private(set) SeasonRepository $seasonRepository;
protected private(set) UserRepository $userRepository;
protected function setUp(): void
{
$this->entityManager = self::getContainer()->get(EntityManagerInterface::class);
$this->candidateRepository = self::getContainer()->get(CandidateRepository::class);
$this->questionRepository = self::getContainer()->get(QuestionRepository::class);
$this->quizCandidateRepository = self::getContainer()->get(QuizCandidateRepository::class);
$this->quizRepository = self::getContainer()->get(QuizRepository::class);
$this->seasonRepository = self::getContainer()->get(SeasonRepository::class);
$this->userRepository = self::getContainer()->get(UserRepository::class);
}
protected function getUserByEmail(string $email): User
{
$user = $this->userRepository->findOneBy(['email' => $email]);
$this->assertInstanceOf(User::class, $user);
return $user;
}
protected function getSeasonByCode(string $code): Season
{
$season = $this->seasonRepository->findOneBySeasonCode($code);
$this->assertInstanceOf(Season::class, $season);
return $season;
}
protected function getCandidateBySeasonAndName(Season $season, string $name): Candidate
{
$candidate = $this->candidateRepository->findOneBy(['season' => $season, 'name' => $name]);
$this->assertInstanceOf(Candidate::class, $candidate);
return $candidate;
}
}

View File

@@ -1,87 +0,0 @@
<?php
declare(strict_types=1);
namespace Tvdt\Tests\Repository;
use PHPUnit\Framework\Attributes\CoversClass;
use Tvdt\Entity\Answer;
use Tvdt\Entity\Candidate;
use Tvdt\Entity\GivenAnswer;
use Tvdt\Entity\Question;
use Tvdt\Entity\Quiz;
use Tvdt\Repository\QuestionRepository;
#[CoversClass(QuestionRepository::class)]
final class QuestionRepositoryTest extends DatabaseTestCase
{
public function testFindNextQuestionReturnsRightQuestion(): void
{
$krtekSeason = $this->getSeasonByCode('krtek');
$candidate = $this->getCandidateBySeasonAndName($krtekSeason, 'Tom');
$question = $this->questionRepository->findNextQuestionForCandidate($candidate);
$this->assertInstanceOf(Question::class, $question);
$this->assertSame('Is de Krtek een man of een vrouw?', $question->question, 'Wrong first question');
$this->answerQuestion($question, $candidate);
$question = $this->questionRepository->findNextQuestionForCandidate($candidate);
$this->assertInstanceOf(Question::class, $question);
$this->assertSame('Hoeveel broers heeft de Krtek?', $question->question, 'Wrong second question');
$question = $this->questionRepository->findNextQuestionForCandidate($candidate);
$this->assertInstanceOf(Question::class, $question);
$this->assertSame('Hoeveel broers heeft de Krtek?', $question->question, 'Getting question a second time fails');
$quiz = $krtekSeason->quizzes->last();
$this->assertInstanceOf(Quiz::class, $quiz);
$krtekSeason->activeQuiz = $quiz;
$this->entityManager->flush();
$question = $this->questionRepository->findNextQuestionForCandidate($candidate);
$this->assertInstanceOf(Question::class, $question);
$this->assertSame('Is de Krtek een man of een vrouw?', $question->question, 'Wrong question after switching season.');
}
public function testFindNextQuestionGivesNullWhenAllQuestionsAnswered(): void
{
$krtekSeason = $this->getSeasonByCode('krtek');
$candidate = $this->getCandidateBySeasonAndName($krtekSeason, 'Tom');
for ($i = 0; $i < 15; ++$i) {
$question = $this->questionRepository->findNextQuestionForCandidate($candidate);
$this->assertInstanceOf(Question::class, $question);
$this->answerQuestion($question, $candidate);
}
$question = $this->questionRepository->findNextQuestionForCandidate($candidate);
$this->assertNotInstanceOf(Question::class, $question);
}
public function testFindNextQuestionWithNoActiveQuizReturnsNull(): void
{
$krtekSeason = $this->getSeasonByCode('krtek');
$candidate = $this->getCandidateBySeasonAndName($krtekSeason, 'Tom');
$krtekSeason->activeQuiz = null;
$this->entityManager->flush();
$question = $this->questionRepository->findNextQuestionForCandidate($candidate);
$this->assertNotInstanceOf(Question::class, $question);
}
private function answerQuestion(Question $question, Candidate $candidate): void
{
$answer = $question->answers->first();
$this->assertInstanceOf(Answer::class, $answer);
$this->entityManager->persist(new GivenAnswer(
$candidate,
$question->quiz,
$answer,
));
$this->entityManager->flush();
}
}

View File

@@ -1,72 +0,0 @@
<?php
declare(strict_types=1);
namespace Tvdt\Tests\Repository;
use PHPUnit\Framework\Attributes\CoversClass;
use Tvdt\Entity\Quiz;
use Tvdt\Entity\QuizCandidate;
use Tvdt\Repository\QuizCandidateRepository;
#[CoversClass(QuizCandidateRepository::class)]
final class QuizCandidateRepositoryTest extends DatabaseTestCase
{
public function testCreateIfNotExists(): void
{
$krtekSeason = $this->getSeasonByCode('krtek');
$candidate = $this->getCandidateBySeasonAndName($krtekSeason, 'Myrthe');
$quiz = $krtekSeason->activeQuiz;
$this->assertInstanceOf(Quiz::class, $quiz);
$result = $this->quizCandidateRepository->createIfNotExist($quiz, $candidate);
$this->assertTrue($result);
$quizCandidate = $this->quizCandidateRepository->findOneBy([
'candidate' => $candidate,
'quiz' => $quiz,
]);
$this->assertInstanceOf(QuizCandidate::class, $quizCandidate);
$result = $this->quizCandidateRepository->createIfNotExist($quiz, $candidate);
$this->assertFalse($result);
}
public function testSetCorrectionsForCandidateUpdatesCandidateCorrectly(): void
{
$krtekSeason = $this->getSeasonByCode('krtek');
$candidate = $this->getCandidateBySeasonAndName($krtekSeason, 'Myrthe');
$quiz = $krtekSeason->activeQuiz;
$this->assertInstanceOf(Quiz::class, $quiz);
$this->quizCandidateRepository->createIfNotExist($quiz, $candidate);
$this->quizCandidateRepository->setCorrectionsForCandidate(
$quiz, $candidate, 3.5,
);
$quizCandidate = $this->quizCandidateRepository->findOneBy([
'candidate' => $candidate,
'quiz' => $quiz,
]);
$this->assertInstanceOf(QuizCandidate::class, $quizCandidate);
$this->assertEqualsWithDelta(3.5, $quizCandidate->corrections, 0.1);
}
public function testCannotGiveCorrectionsToCandidateWithoutResult(): void
{
$krtekSeason = $this->getSeasonByCode('krtek');
$candidate = $this->getCandidateBySeasonAndName($krtekSeason, 'Myrthe');
$quiz = $krtekSeason->activeQuiz;
$this->assertInstanceOf(Quiz::class, $quiz);
$this->expectException(\InvalidArgumentException::class);
$this->quizCandidateRepository->setCorrectionsForCandidate(
$quiz, $candidate, 3.5,
);
}
}

View File

@@ -1,214 +0,0 @@
<?php
declare(strict_types=1);
namespace Tvdt\Tests\Repository;
use PHPUnit\Framework\Attributes\CoversClass;
use Psr\Clock\ClockInterface;
use Symfony\Component\Clock\MockClock;
use Tvdt\Entity\Answer;
use Tvdt\Entity\GivenAnswer;
use Tvdt\Entity\Question;
use Tvdt\Entity\Quiz;
use Tvdt\Entity\QuizCandidate;
use Tvdt\Repository\GivenAnswerRepository;
use Tvdt\Repository\QuizRepository;
#[CoversClass(QuizRepository::class)]
final class QuizRepositoryTest extends DatabaseTestCase
{
public function testClearQuiz(): void
{
$krtekSeason = $this->getSeasonByCode('krtek');
$quiz = $krtekSeason->activeQuiz;
$this->assertInstanceOf(Quiz::class, $quiz);
$this->quizRepository->clearQuiz($quiz);
$this->entityManager->refresh($krtekSeason);
$this->assertEmpty($quiz->candidateData);
$this->assertEmpty($quiz->eliminations);
/** @var GivenAnswerRepository $givenAnswerRepository */
$givenAnswerRepository = self::getContainer()->get(GivenAnswerRepository::class);
$this->assertEmpty($givenAnswerRepository->findBy(['quiz' => $quiz]));
}
public function testDeleteQuiz(): void
{
$krtekSeason = $this->getSeasonByCode('krtek');
$quiz = $krtekSeason->quizzes->last();
$this->assertInstanceOf(Quiz::class, $quiz);
$this->quizRepository->deleteQuiz($quiz);
$this->entityManager->refresh($krtekSeason);
$this->assertCount(1, $krtekSeason->quizzes);
}
public function testTimeForCandidate(): void
{
$clock = new MockClock('2025-11-01 16:00:00');
self::getContainer()->set(ClockInterface::class, $clock);
$krtekSeason = $this->getSeasonByCode('krtek');
$candidate = $this->getCandidateBySeasonAndName($krtekSeason, 'Iris');
$quiz = $krtekSeason->activeQuiz;
$this->assertInstanceOf(Quiz::class, $quiz);
// Start Quiz
$qc = new QuizCandidate($quiz, $candidate);
$this->entityManager->persist($qc);
$this->entityManager->flush();
for ($i = 0; $i < 15; ++$i) {
$question = $this->questionRepository->findNextQuestionForCandidate($candidate);
$this->assertInstanceOf(Question::class, $question);
$answer = $question->answers->first();
$this->assertInstanceOf(Answer::class, $answer);
$clock->sleep(10 + $i);
$qa = new GivenAnswer($candidate, $quiz, $answer);
$this->entityManager->persist($qa);
$this->entityManager->flush();
}
$result = $this->quizRepository->getScores($quiz);
$this->assertSame('Iris', $result[0]->name);
$this->assertSame(5, $result[0]->correct);
$this->assertEqualsWithDelta(5.0, $result[0]->score, \PHP_FLOAT_EPSILON);
$this->assertSame(4, $result[0]->time->i);
$this->assertSame(15, $result[0]->time->s);
}
public function testScoresAreCalculatedCorrectly(): void
{
$clock = new MockClock('2025-11-01 16:00:00');
self::getContainer()->set(ClockInterface::class, $clock);
$krtekSeason = $this->getSeasonByCode('krtek');
$candidate1 = $this->getCandidateBySeasonAndName($krtekSeason, 'Iris');
$candidate2 = $this->getCandidateBySeasonAndName($krtekSeason, 'Philine');
$quiz = $krtekSeason->activeQuiz;
$this->assertInstanceOf(Quiz::class, $quiz);
$qc1 = new QuizCandidate($quiz, $candidate1);
$qc2 = new QuizCandidate($quiz, $candidate2);
$this->entityManager->persist($qc1);
$this->entityManager->persist($qc2);
$this->entityManager->flush();
for ($i = 0; $i < 15; ++$i) {
$question = $this->questionRepository->findNextQuestionForCandidate($candidate1);
$this->assertInstanceOf(Question::class, $question);
$answer1 = $question->answers->first();
$answer2 = $question->answers[intdiv(\count($question->answers), 2)];
$this->assertInstanceOf(Answer::class, $answer1);
$this->assertInstanceOf(Answer::class, $answer2);
$clock->sleep(10);
$qa = new GivenAnswer($candidate1, $quiz, $answer1);
$this->entityManager->persist($qa);
$qa = new GivenAnswer($candidate2, $quiz, $answer2);
$this->entityManager->persist($qa);
$this->entityManager->flush();
}
$scores = $this->quizRepository->getScores($quiz);
$this->assertCount(2, $scores);
$this->assertSame('Iris', $scores[0]->name);
$this->assertSame('Philine', $scores[1]->name);
$this->assertEqualsWithDelta(5.0, $scores[0]->score, \PHP_FLOAT_EPSILON);
$this->assertEqualsWithDelta(4.0, $scores[1]->score, \PHP_FLOAT_EPSILON);
}
public function testCorrectionsCalculatedCorrectly(): void
{
$clock = new MockClock('2025-11-01 16:00:00');
self::getContainer()->set(ClockInterface::class, $clock);
$krtekSeason = $this->getSeasonByCode('krtek');
$candidate = $this->getCandidateBySeasonAndName($krtekSeason, 'Iris');
$quiz = $krtekSeason->activeQuiz;
$this->assertInstanceOf(Quiz::class, $quiz);
$qc = new QuizCandidate($quiz, $candidate);
$this->entityManager->persist($qc);
$this->entityManager->flush();
for ($i = 0; $i < 15; ++$i) {
$question = $this->questionRepository->findNextQuestionForCandidate($candidate);
$this->assertInstanceOf(Question::class, $question);
$answer = $question->answers->first();
$this->assertInstanceOf(Answer::class, $answer);
$clock->sleep(10);
$qa = new GivenAnswer($candidate, $quiz, $answer);
$this->entityManager->persist($qa);
$this->entityManager->flush();
}
$qc->corrections = 2;
$this->entityManager->flush();
$result = $this->quizRepository->getScores($quiz);
$this->assertEqualsWithDelta(7.0, $result[0]->score, \PHP_FLOAT_EPSILON);
}
public function testCandidatesWithSameScoreAreSortedCorrectlyByTime(): void
{
$clock = new MockClock('2025-11-01 16:00:00');
self::getContainer()->set(ClockInterface::class, $clock);
$krtekSeason = $this->getSeasonByCode('krtek');
$candidate1 = $this->getCandidateBySeasonAndName($krtekSeason, 'Iris');
$candidate2 = $this->getCandidateBySeasonAndName($krtekSeason, 'Philine');
$quiz = $krtekSeason->activeQuiz;
$this->assertInstanceOf(Quiz::class, $quiz);
$qc1 = new QuizCandidate($quiz, $candidate1);
$this->entityManager->persist($qc1);
$clock->sleep(10);
$qc2 = new QuizCandidate($quiz, $candidate2);
$this->entityManager->persist($qc2);
$this->entityManager->flush();
for ($i = 0; $i < 15; ++$i) {
$question = $this->questionRepository->findNextQuestionForCandidate($candidate1);
$this->assertInstanceOf(Question::class, $question);
$answer1 = $question->answers->first();
$answer2 = $question->answers->last();
$this->assertInstanceOf(Answer::class, $answer1);
$this->assertInstanceOf(Answer::class, $answer2);
$clock->sleep(10);
$qa = new GivenAnswer($candidate1, $quiz, $answer1);
$this->entityManager->persist($qa);
$qa = new GivenAnswer($candidate2, $quiz, $answer2);
$this->entityManager->persist($qa);
$this->entityManager->flush();
}
$result = $this->quizRepository->getScores($quiz);
$this->assertEqualsWithDelta(5.0, $result[0]->score, \PHP_FLOAT_EPSILON);
$this->assertEqualsWithDelta(5.0, $result[1]->score, \PHP_FLOAT_EPSILON);
$this->assertSame('Philine', $result[0]->name);
$this->assertSame('Iris', $result[1]->name);
}
}

View File

@@ -1,59 +0,0 @@
<?php
declare(strict_types=1);
namespace Tvdt\Tests\Repository;
use PHPUnit\Framework\Attributes\CoversClass;
use Tvdt\Entity\Season;
use Tvdt\Repository\SeasonRepository;
#[CoversClass(SeasonRepository::class)]
final class SeasonRepositoryTest extends DatabaseTestCase
{
public function testGetSeasonsForUser(): void
{
$user = $this->getUserByEmail('krtek-admin@example.org');
$seasons = $this->seasonRepository->getSeasonsForUser($user);
$this->assertCount(1, $seasons);
$this->assertSame('krtek', $seasons[0]->seasonCode);
$user = $this->getUserByEmail('user1@example.org');
$seasons = $this->seasonRepository->getSeasonsForUser($user);
$this->assertCount(1, $seasons);
$this->assertSame('bbbbb', $seasons[0]->seasonCode);
}
public function testUserWithMultipleSeasons(): void
{
$user = $this->getUserByEmail('user2@example.org');
$seasons = $this->seasonRepository->getSeasonsForUser($user);
$this->assertCount(2, $seasons);
$this->assertSame('bbbbb', $seasons[0]->seasonCode);
$this->assertSame('krtek', $seasons[1]->seasonCode);
}
public function testGetSeasonsForUserWithoutSeasonsReturnsEmpty(): void
{
$user = $this->getUserByEmail('test@example.org');
$seasons = $this->seasonRepository->getSeasonsForUser($user);
$this->assertEmpty($seasons);
}
public function testFindOneBySeasonCode(): void
{
$season = $this->seasonRepository->findOneBySeasonCode('krtek');
$this->assertInstanceOf(Season::class, $season);
$this->assertSame('krtek', $season->seasonCode);
}
public function testFindOneBySeasonCodeUnknownSeasonReturnsNull(): void
{
$season = $this->seasonRepository->findOneBySeasonCode('invalid');
$this->assertNotInstanceOf(Season::class, $season);
}
}

View File

@@ -1,45 +0,0 @@
<?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');
}
}

View File

@@ -4,13 +4,11 @@ declare(strict_types=1);
namespace Tvdt\Tests\Security\Voter; namespace Tvdt\Tests\Security\Voter;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\MockObject\Stub; use PHPUnit\Framework\MockObject\Stub;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface; use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use Tvdt\Entity\Answer; use Tvdt\Entity\Answer;
use Tvdt\Entity\Candidate; use Tvdt\Entity\Candidate;
use Tvdt\Entity\Elimination; use Tvdt\Entity\Elimination;
@@ -20,7 +18,6 @@ use Tvdt\Entity\Season;
use Tvdt\Entity\User; use Tvdt\Entity\User;
use Tvdt\Security\Voter\SeasonVoter; use Tvdt\Security\Voter\SeasonVoter;
#[CoversClass(SeasonVoter::class)]
final class SeasonVoterTest extends TestCase final class SeasonVoterTest extends TestCase
{ {
private SeasonVoter $seasonVoter; private SeasonVoter $seasonVoter;
@@ -54,58 +51,27 @@ final class SeasonVoterTest extends TestCase
{ {
$season = self::createStub(Season::class); $season = self::createStub(Season::class);
$season->method('isOwner')->willReturn(true); $season->method('isOwner')->willReturn(true);
yield 'Season' => [$season];
$candidate = self::createStub(Candidate::class);
$candidate->season = $season;
yield 'Candidate' => [$candidate];
$quiz = self::createStub(Quiz::class); $quiz = self::createStub(Quiz::class);
$quiz->season = $season; $quiz->method('getSeason')->willReturn($season);
yield 'Quiz' => [$quiz];
$elimination = self::createStub(Elimination::class); $elimination = self::createStub(Elimination::class);
$elimination->quiz = $quiz; $elimination->method('getQuiz')->willReturn($quiz);
yield 'Elimination' => [$elimination];
$candidate = self::createStub(Candidate::class);
$candidate->method('getSeason')->willReturn($season);
$question = self::createStub(Question::class); $question = self::createStub(Question::class);
$question->quiz = $quiz; $question->method('getQuiz')->willReturn($quiz);
yield 'Question' => [$question];
$answer = self::createStub(Answer::class); $answer = self::createStub(Answer::class);
$answer->question = $question; $answer->method('getQuestion')->willReturn($question);
yield 'Season' => [$season];
yield 'Elimination' => [$elimination];
yield 'Quiz' => [$quiz];
yield 'Candidate' => [$candidate];
yield 'Question' => [$question];
yield 'Answer' => [$answer]; yield 'Answer' => [$answer];
} }
public function testWrongUserTypeReturnFalse(): void
{
$user = self::createStub(UserInterface::class);
$token = $this->createStub(TokenInterface::class);
$token->method('getUser')->willReturn($user);
$this->assertSame(VoterInterface::ACCESS_DENIED, $this->seasonVoter->vote($token, new Season(), ['SEASON_EDIT']));
}
public function testAdminCanDoAnything(): void
{
$user = new User();
$user->roles = ['ROLE_ADMIN'];
$token = $this->createStub(TokenInterface::class);
$token->method('getUser')->willReturn($user);
$this->assertSame(VoterInterface::ACCESS_GRANTED, $this->seasonVoter->vote($token, new Season(), ['SEASON_EDIT']));
}
public function testRandomClassWillAbstain(): void
{
$subject = new \stdClass();
$this->assertSame(VoterInterface::ACCESS_ABSTAIN, $this->seasonVoter->vote($this->token, $subject, ['SEASON_EDIT']));
}
public function testRandomSunjectWillAbstain(): void
{
$subject = new Season();
$this->assertSame(VoterInterface::ACCESS_ABSTAIN, $this->seasonVoter->vote($this->token, $subject, ['DO_NOTHING']));
}
} }

View File

@@ -1,11 +0,0 @@
<?php
declare(strict_types=1);
use Tvdt\Kernel;
require __DIR__.'/bootstrap.php';
$appKernel = new Kernel('test', false);
$appKernel->boot();
return $appKernel->getContainer();