From 7b05e52d9546fc87724a952dadb1efa35050504d Mon Sep 17 00:00:00 2001 From: Marijn Doeve Date: Tue, 22 Apr 2025 22:24:17 +0200 Subject: [PATCH] A lot --- .env.test | 4 + .gitignore | 7 +- .idea/TijdVoorDeTest.iml | 7 +- .idea/inspectionProfiles/Project_Default.xml | 68 +++ .idea/php-test-framework.xml | 2 +- .idea/php.xml | 48 +- .idea/remote-mappings.xml | 16 + .php-cs-fixer.dist.php | 1 + Dockerfile | 1 + composer.json | 11 +- composer.lock | 430 +++++++----------- config/bundles.php | 20 +- config/packages/framework.yaml | 9 +- phpunit.dist.xml | 34 ++ src/Command/MakeAdminCommand.php | 52 +++ src/Controller/Admin/AnswerCrudController.php | 14 - .../Admin/CandidateCrudController.php | 14 - .../Admin/CorrectionCrudController.php | 14 - src/Controller/Admin/DashboardController.php | 8 +- .../Admin/GivenAnswerCrudController.php | 14 - .../Admin/QuestionCrudController.php | 14 - src/Controller/Admin/QuizCrudController.php | 14 - src/Controller/Admin/SeasonCrudController.php | 14 - src/Controller/Admin/UserCrudController.php | 14 - src/Repository/UserRepository.php | 11 + symfony.lock | 23 +- templates/backoffice/base.html.twig | 1 + templates/quiz/base.html.twig | 1 + tests/bootstrap.php | 6 +- 29 files changed, 441 insertions(+), 431 deletions(-) create mode 100644 .env.test create mode 100644 .idea/remote-mappings.xml create mode 100644 phpunit.dist.xml create mode 100644 src/Command/MakeAdminCommand.php diff --git a/.env.test b/.env.test new file mode 100644 index 0000000..24a43c0 --- /dev/null +++ b/.env.test @@ -0,0 +1,4 @@ +# define your env variables for the test env here +KERNEL_CLASS='App\Kernel' +APP_SECRET='$ecretf0rt3st' +SYMFONY_DEPRECATIONS_HELPER=999999 diff --git a/.gitignore b/.gitignore index 803f32b..7c932e2 100644 --- a/.gitignore +++ b/.gitignore @@ -103,9 +103,14 @@ phpstan.neon ###< friendsofphp/php-cs-fixer ### ###> phpunit/phpunit ### /phpunit.xml -.phpunit.result.cache +/.phpunit.cache/ ###< phpunit/phpunit ### ###> vincentlanglet/twig-cs-fixer ### /.twig-cs-fixer.cache ###< vincentlanglet/twig-cs-fixer ### + +###> symfony/phpunit-bridge ### +.phpunit.result.cache +/phpunit.xml +###< symfony/phpunit-bridge ### diff --git a/.idea/TijdVoorDeTest.iml b/.idea/TijdVoorDeTest.iml index f619663..e100f40 100644 --- a/.idea/TijdVoorDeTest.iml +++ b/.idea/TijdVoorDeTest.iml @@ -81,7 +81,6 @@ - @@ -102,7 +101,6 @@ - @@ -136,7 +134,6 @@ - @@ -147,6 +144,10 @@ + + + + diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml index 325e2c7..332b63f 100644 --- a/.idea/inspectionProfiles/Project_Default.xml +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -1,6 +1,74 @@ diff --git a/.idea/php-test-framework.xml b/.idea/php-test-framework.xml index 59f6b0c..527878e 100644 --- a/.idea/php-test-framework.xml +++ b/.idea/php-test-framework.xml @@ -5,7 +5,7 @@ - + diff --git a/.idea/php.xml b/.idea/php.xml index 6824dc5..93a156e 100644 --- a/.idea/php.xml +++ b/.idea/php.xml @@ -1,32 +1,20 @@ - - - - - - - - - - - - + + + - + @@ -38,7 +26,6 @@ - @@ -127,7 +114,6 @@ - @@ -165,7 +151,6 @@ - @@ -177,11 +162,13 @@ + + - + @@ -195,15 +182,15 @@ - - + + /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini, /usr/local/etc/php/conf.d/docker-php-ext-intl.ini, /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini, /usr/local/etc/php/conf.d/docker-php-ext-pdo_pgsql.ini, /usr/local/etc/php/conf.d/docker-php-ext-sodium.ini, /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini, /usr/local/etc/php/conf.d/docker-php-ext-zip.ini, /usr/local/etc/php/app.conf.d/10-app.ini, /usr/local/etc/php/app.conf.d/20-app.dev.ini /usr/local/etc/php/php.ini - + @@ -255,27 +242,24 @@ - - + + - - + - + - - \ No newline at end of file diff --git a/.idea/remote-mappings.xml b/.idea/remote-mappings.xml new file mode 100644 index 0000000..2ba49b9 --- /dev/null +++ b/.idea/remote-mappings.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 603199b..b4b7a6c 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -8,6 +8,7 @@ use PhpCsFixer\Runner\Parallel\ParallelConfigFactory; $finder = (new Finder()) ->in(__DIR__) ->exclude('var') + ->exclude('bin') ; return (new Config()) diff --git a/Dockerfile b/Dockerfile index e2e98ee..c224436 100644 --- a/Dockerfile +++ b/Dockerfile @@ -31,6 +31,7 @@ RUN set -eux; \ intl \ opcache \ zip \ + uuid \ ; # https://getcomposer.org/doc/03-cli.md#composer-allow-superuser diff --git a/composer.json b/composer.json index 890404c..3d3708a 100644 --- a/composer.json +++ b/composer.json @@ -40,11 +40,13 @@ "phpstan/phpstan-doctrine": "^2.0.2", "phpstan/phpstan-phpunit": "^2.0.6", "phpstan/phpstan-symfony": "^2.0.4", - "phpunit/phpunit": "^12.1.2", - "rector/rector": "^2.0.11", + "phpunit/phpunit": "^12.1.3", + "rector/rector": "^2.0.12", "roave/security-advisories": "dev-latest", "symfony/browser-kit": "7.2.*", + "symfony/css-selector": "7.2.*", "symfony/maker-bundle": "^1.62.1", + "symfony/phpunit-bridge": "^7.2", "symfony/stopwatch": "7.2.*", "symfony/web-profiler-bundle": "7.2.*", "thecodingmachine/phpstan-safe-rule": "^1.4", @@ -73,12 +75,15 @@ "replace": { "symfony/polyfill-ctype": "*", "symfony/polyfill-iconv": "*", + "symfony/polyfill-mbstring": "*", "symfony/polyfill-php72": "*", "symfony/polyfill-php73": "*", "symfony/polyfill-php74": "*", "symfony/polyfill-php80": "*", "symfony/polyfill-php81": "*", - "symfony/polyfill-php82": "*" + "symfony/polyfill-php82": "*", + "symfony/polyfill-php83": "*", + "symfony/polyfill-uuid": "*" }, "scripts": { "auto-scripts": { diff --git a/composer.lock b/composer.lock index dafdf33..96c3b6f 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "4f1a4b1f2a93612d13032cda491c6271", + "content-hash": "a9d6270ea237ce82ff39532fe4582a81", "packages": [ { "name": "doctrine/collections", @@ -4683,162 +4683,6 @@ ], "time": "2024-09-09T11:45:10+00:00" }, - { - "name": "symfony/polyfill-mbstring", - "version": "v1.31.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/85181ba99b2345b0ef10ce42ecac37612d9fd341", - "reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341", - "shasum": "" - }, - "require": { - "php": ">=7.2" - }, - "provide": { - "ext-mbstring": "*" - }, - "suggest": { - "ext-mbstring": "For best performance" - }, - "type": "library", - "extra": { - "thanks": { - "url": "https://github.com/symfony/polyfill", - "name": "symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Mbstring\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for the Mbstring extension", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "mbstring", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.31.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2024-09-09T11:45:10+00:00" - }, - { - "name": "symfony/polyfill-php83", - "version": "v1.31.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php83.git", - "reference": "2fb86d65e2d424369ad2905e83b236a8805ba491" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php83/zipball/2fb86d65e2d424369ad2905e83b236a8805ba491", - "reference": "2fb86d65e2d424369ad2905e83b236a8805ba491", - "shasum": "" - }, - "require": { - "php": ">=7.2" - }, - "type": "library", - "extra": { - "thanks": { - "url": "https://github.com/symfony/polyfill", - "name": "symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Php83\\": "" - }, - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 8.3+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-php83/tree/v1.31.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2024-09-09T11:45:10+00:00" - }, { "name": "symfony/polyfill-php84", "version": "v1.31.0", @@ -4915,85 +4759,6 @@ ], "time": "2024-09-09T12:04:04+00:00" }, - { - "name": "symfony/polyfill-uuid", - "version": "v1.31.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-uuid.git", - "reference": "21533be36c24be3f4b1669c4725c7d1d2bab4ae2" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-uuid/zipball/21533be36c24be3f4b1669c4725c7d1d2bab4ae2", - "reference": "21533be36c24be3f4b1669c4725c7d1d2bab4ae2", - "shasum": "" - }, - "require": { - "php": ">=7.2" - }, - "provide": { - "ext-uuid": "*" - }, - "suggest": { - "ext-uuid": "For best performance" - }, - "type": "library", - "extra": { - "thanks": { - "url": "https://github.com/symfony/polyfill", - "name": "symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Uuid\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Grégoire Pineau", - "email": "lyrixx@lyrixx.info" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for uuid functions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "uuid" - ], - "support": { - "source": "https://github.com/symfony/polyfill-uuid/tree/v1.31.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2024-09-09T11:45:10+00:00" - }, { "name": "symfony/property-access", "version": "v7.2.3", @@ -8746,16 +8511,16 @@ }, { "name": "phpunit/phpunit", - "version": "12.1.2", + "version": "12.1.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "6f2775cc4b7b19ba5a411c188e855eb0cc78a711" + "reference": "72ca50e817dd7d65356c16772c30f06c01a6fae2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/6f2775cc4b7b19ba5a411c188e855eb0cc78a711", - "reference": "6f2775cc4b7b19ba5a411c188e855eb0cc78a711", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/72ca50e817dd7d65356c16772c30f06c01a6fae2", + "reference": "72ca50e817dd7d65356c16772c30f06c01a6fae2", "shasum": "" }, "require": { @@ -8823,7 +8588,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/12.1.2" + "source": "https://github.com/sebastianbergmann/phpunit/tree/12.1.3" }, "funding": [ { @@ -8834,12 +8599,20 @@ "url": "https://github.com/sebastianbergmann", "type": "github" }, + { + "url": "https://liberapay.com/sebastianbergmann", + "type": "liberapay" + }, + { + "url": "https://thanks.dev/u/gh/sebastianbergmann", + "type": "thanks_dev" + }, { "url": "https://tidelift.com/funding/github/packagist/phpunit/phpunit", "type": "tidelift" } ], - "time": "2025-04-08T08:05:27+00:00" + "time": "2025-04-22T06:11:09+00:00" }, { "name": "react/cache", @@ -9369,21 +9142,21 @@ }, { "name": "rector/rector", - "version": "2.0.11", + "version": "2.0.12", "source": { "type": "git", "url": "https://github.com/rectorphp/rector.git", - "reference": "059b827cc648929711606e9824337e41e2f9ed92" + "reference": "a7f9b968f6c15abfd0d2a1442c9dcd9ade677192" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/rectorphp/rector/zipball/059b827cc648929711606e9824337e41e2f9ed92", - "reference": "059b827cc648929711606e9824337e41e2f9ed92", + "url": "https://api.github.com/repos/rectorphp/rector/zipball/a7f9b968f6c15abfd0d2a1442c9dcd9ade677192", + "reference": "a7f9b968f6c15abfd0d2a1442c9dcd9ade677192", "shasum": "" }, "require": { "php": "^7.4|^8.0", - "phpstan/phpstan": "^2.1.9" + "phpstan/phpstan": "^2.1.12" }, "conflict": { "rector/rector-doctrine": "*", @@ -9416,7 +9189,7 @@ ], "support": { "issues": "https://github.com/rectorphp/rector/issues", - "source": "https://github.com/rectorphp/rector/tree/2.0.11" + "source": "https://github.com/rectorphp/rector/tree/2.0.12" }, "funding": [ { @@ -9424,7 +9197,7 @@ "type": "github" } ], - "time": "2025-03-28T10:25:17+00:00" + "time": "2025-04-22T12:47:33+00:00" }, { "name": "roave/security-advisories", @@ -9432,12 +9205,12 @@ "source": { "type": "git", "url": "https://github.com/Roave/SecurityAdvisories.git", - "reference": "6c54d20ae795b83ecf3f826311d7f488cd1ef005" + "reference": "38570c96303a807d5e530e00a1a238132ca5d84a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/6c54d20ae795b83ecf3f826311d7f488cd1ef005", - "reference": "6c54d20ae795b83ecf3f826311d7f488cd1ef005", + "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/38570c96303a807d5e530e00a1a238132ca5d84a", + "reference": "38570c96303a807d5e530e00a1a238132ca5d84a", "shasum": "" }, "conflict": { @@ -9551,7 +9324,7 @@ "concrete5/core": "<8.5.8|>=9,<9.1", "contao-components/mediaelement": ">=2.14.2,<2.21.1", "contao/comments-bundle": ">=2,<4.13.40|>=5.0.0.0-RC1-dev,<5.3.4", - "contao/contao": "<=5.4.1", + "contao/contao": ">=3,<3.5.37|>=4,<4.4.56|>=4.5,<4.9.40|>=4.10,<4.11.7|>=4.13,<4.13.21|>=5.1,<5.1.4", "contao/core": "<3.5.39", "contao/core-bundle": "<4.13.54|>=5,<5.3.30|>=5.4,<5.5.6", "contao/listing-bundle": ">=3,<=3.5.30|>=4,<4.4.8", @@ -9664,7 +9437,7 @@ "firebase/php-jwt": "<6", "fisharebest/webtrees": "<=2.1.18", "fixpunkt/fp-masterquiz": "<2.2.1|>=3,<3.5.2", - "fixpunkt/fp-newsletter": "<1.1.1|>=2,<2.1.2|>=2.2,<3.2.6", + "fixpunkt/fp-newsletter": "<1.1.1|>=1.2,<2.1.2|>=2.2,<3.2.6", "flarum/core": "<1.8.10", "flarum/flarum": "<0.1.0.0-beta8", "flarum/framework": "<1.8.10", @@ -10351,7 +10124,7 @@ "type": "tidelift" } ], - "time": "2025-04-17T15:05:22+00:00" + "time": "2025-04-22T16:06:15+00:00" }, { "name": "sebastian/cli-parser", @@ -11286,6 +11059,71 @@ ], "time": "2025-02-14T14:27:24+00:00" }, + { + "name": "symfony/css-selector", + "version": "v7.2.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/css-selector.git", + "reference": "601a5ce9aaad7bf10797e3663faefce9e26c24e2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/css-selector/zipball/601a5ce9aaad7bf10797e3663faefce9e26c24e2", + "reference": "601a5ce9aaad7bf10797e3663faefce9e26c24e2", + "shasum": "" + }, + "require": { + "php": ">=8.2" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\CssSelector\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Jean-François Simon", + "email": "jeanfrancois.simon@sensiolabs.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Converts CSS selectors to XPath expressions", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/css-selector/tree/v7.2.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-09-25T14:21:43+00:00" + }, { "name": "symfony/dom-crawler", "version": "v7.2.4", @@ -11445,6 +11283,88 @@ ], "time": "2025-01-15T00:21:40+00:00" }, + { + "name": "symfony/phpunit-bridge", + "version": "v7.2.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/phpunit-bridge.git", + "reference": "2bbde92ab25a0e2c88160857af7be9db5da0d145" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/phpunit-bridge/zipball/2bbde92ab25a0e2c88160857af7be9db5da0d145", + "reference": "2bbde92ab25a0e2c88160857af7be9db5da0d145", + "shasum": "" + }, + "require": { + "php": ">=7.2.5" + }, + "conflict": { + "phpunit/phpunit": "<7.5|9.1.2" + }, + "require-dev": { + "symfony/deprecation-contracts": "^2.5|^3.0", + "symfony/error-handler": "^5.4|^6.4|^7.0", + "symfony/polyfill-php81": "^1.27" + }, + "bin": [ + "bin/simple-phpunit" + ], + "type": "symfony-bridge", + "extra": { + "thanks": { + "url": "https://github.com/sebastianbergmann/phpunit", + "name": "phpunit/phpunit" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Bridge\\PhpUnit\\": "" + }, + "exclude-from-classmap": [ + "/Tests/", + "/bin/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides utilities for PHPUnit, especially user deprecation notices management", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/phpunit-bridge/tree/v7.2.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-11-13T16:15:23+00:00" + }, { "name": "symfony/process", "version": "v7.2.5", diff --git a/config/bundles.php b/config/bundles.php index 4e50234..2765491 100644 --- a/config/bundles.php +++ b/config/bundles.php @@ -17,17 +17,17 @@ use SymfonyCasts\Bundle\VerifyEmail\SymfonyCastsVerifyEmailBundle; use Twig\Extra\TwigExtraBundle\TwigExtraBundle; return [ - FrameworkBundle::class => ['all' => true], DoctrineBundle::class => ['all' => true], - DoctrineMigrationsBundle::class => ['all' => true], - MakerBundle::class => ['dev' => true], - TwigBundle::class => ['all' => true], - SecurityBundle::class => ['all' => true], - WebProfilerBundle::class => ['dev' => true, 'test' => true], - TwigExtraBundle::class => ['all' => true], - TwigComponentBundle::class => ['all' => true], - EasyAdminBundle::class => ['all' => true], DoctrineFixturesBundle::class => ['dev' => true, 'test' => true], - SymfonyCastsVerifyEmailBundle::class => ['all' => true], + DoctrineMigrationsBundle::class => ['all' => true], + EasyAdminBundle::class => ['all' => true], + FrameworkBundle::class => ['all' => true], + MakerBundle::class => ['dev' => true], + SecurityBundle::class => ['all' => true], SentryBundle::class => ['prod' => true], + SymfonyCastsVerifyEmailBundle::class => ['all' => true], + TwigBundle::class => ['all' => true], + TwigComponentBundle::class => ['all' => true], + TwigExtraBundle::class => ['all' => true], + WebProfilerBundle::class => ['dev' => true, 'test' => true], ]; diff --git a/config/packages/framework.yaml b/config/packages/framework.yaml index d829b41..4d76e69 100644 --- a/config/packages/framework.yaml +++ b/config/packages/framework.yaml @@ -7,8 +7,13 @@ framework: form: csrf_protection: enabled: true - #esi: true - #fragments: true + #esi: true + #fragments: true + + # shortcut for private IP address ranges of your proxy + trusted_proxies: 'private_ranges' + # or, if your proxy instead uses the "Forwarded" header + trusted_headers: [ 'forwarded' ] when@test: framework: diff --git a/phpunit.dist.xml b/phpunit.dist.xml new file mode 100644 index 0000000..0b31da2 --- /dev/null +++ b/phpunit.dist.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + tests + + + + + + src + + + + + + diff --git a/src/Command/MakeAdminCommand.php b/src/Command/MakeAdminCommand.php new file mode 100644 index 0000000..e9034a6 --- /dev/null +++ b/src/Command/MakeAdminCommand.php @@ -0,0 +1,52 @@ +addArgument('email', InputArgument::OPTIONAL, 'The email of the user to make admin') + ; + } + + protected function execute(InputInterface $input, OutputInterface $output): int + { + $io = new SymfonyStyle($input, $output); + $email = $input->getArgument('email'); + + try { + $this->userRepository->makeAdmin($email); + } catch (\InvalidArgumentException) { + $io->error('User not found'); + + return Command::FAILURE; + } + + return Command::SUCCESS; + } +} diff --git a/src/Controller/Admin/AnswerCrudController.php b/src/Controller/Admin/AnswerCrudController.php index a98184f..836e631 100644 --- a/src/Controller/Admin/AnswerCrudController.php +++ b/src/Controller/Admin/AnswerCrudController.php @@ -6,9 +6,6 @@ namespace App\Controller\Admin; use App\Entity\Answer; use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController; -use EasyCorp\Bundle\EasyAdminBundle\Field\IdField; -use EasyCorp\Bundle\EasyAdminBundle\Field\TextEditorField; -use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; class AnswerCrudController extends AbstractCrudController { @@ -16,15 +13,4 @@ class AnswerCrudController extends AbstractCrudController { return Answer::class; } - - /* - public function configureFields(string $pageName): iterable - { - return [ - IdField::new('id'), - TextField::new('title'), - TextEditorField::new('description'), - ]; - } - */ } diff --git a/src/Controller/Admin/CandidateCrudController.php b/src/Controller/Admin/CandidateCrudController.php index 45bd0f6..9acbef6 100644 --- a/src/Controller/Admin/CandidateCrudController.php +++ b/src/Controller/Admin/CandidateCrudController.php @@ -6,9 +6,6 @@ namespace App\Controller\Admin; use App\Entity\Candidate; use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController; -use EasyCorp\Bundle\EasyAdminBundle\Field\IdField; -use EasyCorp\Bundle\EasyAdminBundle\Field\TextEditorField; -use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; class CandidateCrudController extends AbstractCrudController { @@ -16,15 +13,4 @@ class CandidateCrudController extends AbstractCrudController { return Candidate::class; } - - /* - public function configureFields(string $pageName): iterable - { - return [ - IdField::new('id'), - TextField::new('title'), - TextEditorField::new('description'), - ]; - } - */ } diff --git a/src/Controller/Admin/CorrectionCrudController.php b/src/Controller/Admin/CorrectionCrudController.php index abc0758..89b649f 100644 --- a/src/Controller/Admin/CorrectionCrudController.php +++ b/src/Controller/Admin/CorrectionCrudController.php @@ -6,9 +6,6 @@ namespace App\Controller\Admin; use App\Entity\Correction; use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController; -use EasyCorp\Bundle\EasyAdminBundle\Field\IdField; -use EasyCorp\Bundle\EasyAdminBundle\Field\TextEditorField; -use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; class CorrectionCrudController extends AbstractCrudController { @@ -16,15 +13,4 @@ class CorrectionCrudController extends AbstractCrudController { return Correction::class; } - - /* - public function configureFields(string $pageName): iterable - { - return [ - IdField::new('id'), - TextField::new('title'), - TextEditorField::new('description'), - ]; - } - */ } diff --git a/src/Controller/Admin/DashboardController.php b/src/Controller/Admin/DashboardController.php index de1bc3e..0933738 100644 --- a/src/Controller/Admin/DashboardController.php +++ b/src/Controller/Admin/DashboardController.php @@ -12,21 +12,19 @@ use App\Entity\Question; use App\Entity\Quiz; use App\Entity\Season; use App\Entity\User; +use EasyCorp\Bundle\EasyAdminBundle\Attribute\AdminDashboard; use EasyCorp\Bundle\EasyAdminBundle\Config\Dashboard; use EasyCorp\Bundle\EasyAdminBundle\Config\MenuItem; use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractDashboardController; use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\Routing\Attribute\Route; +#[AdminDashboard(routePath: '/admin', routeName: 'admin')] class DashboardController extends AbstractDashboardController { - #[Route('/admin', name: 'admin')] #[\Override] public function index(): Response { - // return parent::index(); - // Option 1. You can make your dashboard redirect to some common page of your backend // $adminUrlGenerator = $this->container->get(AdminUrlGenerator::class); @@ -64,6 +62,6 @@ class DashboardController extends AbstractDashboardController yield MenuItem::linkToCrud('User', 'fas fa-list', User::class); yield MenuItem::linkToCrud('Given Answer', 'fas fa-list', GivenAnswer::class); yield MenuItem::linkToCrud('Answer', 'fas fa-list', Answer::class); - yield MenuItem::linkToLogout('Logout', 'fa fa-exit'); + yield MenuItem::linkToLogout('Logout', 'fas fa-sign-out'); } } diff --git a/src/Controller/Admin/GivenAnswerCrudController.php b/src/Controller/Admin/GivenAnswerCrudController.php index 7ae243a..628b0dc 100644 --- a/src/Controller/Admin/GivenAnswerCrudController.php +++ b/src/Controller/Admin/GivenAnswerCrudController.php @@ -6,9 +6,6 @@ namespace App\Controller\Admin; use App\Entity\GivenAnswer; use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController; -use EasyCorp\Bundle\EasyAdminBundle\Field\IdField; -use EasyCorp\Bundle\EasyAdminBundle\Field\TextEditorField; -use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; class GivenAnswerCrudController extends AbstractCrudController { @@ -16,15 +13,4 @@ class GivenAnswerCrudController extends AbstractCrudController { return GivenAnswer::class; } - - /* - public function configureFields(string $pageName): iterable - { - return [ - IdField::new('id'), - TextField::new('title'), - TextEditorField::new('description'), - ]; - } - */ } diff --git a/src/Controller/Admin/QuestionCrudController.php b/src/Controller/Admin/QuestionCrudController.php index f7a323c..180bdc6 100644 --- a/src/Controller/Admin/QuestionCrudController.php +++ b/src/Controller/Admin/QuestionCrudController.php @@ -6,9 +6,6 @@ namespace App\Controller\Admin; use App\Entity\Question; use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController; -use EasyCorp\Bundle\EasyAdminBundle\Field\IdField; -use EasyCorp\Bundle\EasyAdminBundle\Field\TextEditorField; -use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; class QuestionCrudController extends AbstractCrudController { @@ -16,15 +13,4 @@ class QuestionCrudController extends AbstractCrudController { return Question::class; } - - /* - public function configureFields(string $pageName): iterable - { - return [ - IdField::new('id'), - TextField::new('title'), - TextEditorField::new('description'), - ]; - } - */ } diff --git a/src/Controller/Admin/QuizCrudController.php b/src/Controller/Admin/QuizCrudController.php index 0fa6e8f..f90cded 100644 --- a/src/Controller/Admin/QuizCrudController.php +++ b/src/Controller/Admin/QuizCrudController.php @@ -6,9 +6,6 @@ namespace App\Controller\Admin; use App\Entity\Quiz; use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController; -use EasyCorp\Bundle\EasyAdminBundle\Field\IdField; -use EasyCorp\Bundle\EasyAdminBundle\Field\TextEditorField; -use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; class QuizCrudController extends AbstractCrudController { @@ -16,15 +13,4 @@ class QuizCrudController extends AbstractCrudController { return Quiz::class; } - - /* - public function configureFields(string $pageName): iterable - { - return [ - IdField::new('id'), - TextField::new('title'), - TextEditorField::new('description'), - ]; - } - */ } diff --git a/src/Controller/Admin/SeasonCrudController.php b/src/Controller/Admin/SeasonCrudController.php index 5b01d54..74062d0 100644 --- a/src/Controller/Admin/SeasonCrudController.php +++ b/src/Controller/Admin/SeasonCrudController.php @@ -6,9 +6,6 @@ namespace App\Controller\Admin; use App\Entity\Season; use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController; -use EasyCorp\Bundle\EasyAdminBundle\Field\IdField; -use EasyCorp\Bundle\EasyAdminBundle\Field\TextEditorField; -use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; class SeasonCrudController extends AbstractCrudController { @@ -16,15 +13,4 @@ class SeasonCrudController extends AbstractCrudController { return Season::class; } - - /* - public function configureFields(string $pageName): iterable - { - return [ - IdField::new('id'), - TextField::new('title'), - TextEditorField::new('description'), - ]; - } - */ } diff --git a/src/Controller/Admin/UserCrudController.php b/src/Controller/Admin/UserCrudController.php index fb09ae3..b256a05 100644 --- a/src/Controller/Admin/UserCrudController.php +++ b/src/Controller/Admin/UserCrudController.php @@ -6,9 +6,6 @@ namespace App\Controller\Admin; use App\Entity\User; use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController; -use EasyCorp\Bundle\EasyAdminBundle\Field\IdField; -use EasyCorp\Bundle\EasyAdminBundle\Field\TextEditorField; -use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; class UserCrudController extends AbstractCrudController { @@ -16,15 +13,4 @@ class UserCrudController extends AbstractCrudController { return User::class; } - - /* - public function configureFields(string $pageName): iterable - { - return [ - IdField::new('id'), - TextField::new('title'), - TextEditorField::new('description'), - ]; - } - */ } diff --git a/src/Repository/UserRepository.php b/src/Repository/UserRepository.php index 1d3deaf..1de1324 100644 --- a/src/Repository/UserRepository.php +++ b/src/Repository/UserRepository.php @@ -27,4 +27,15 @@ class UserRepository extends ServiceEntityRepository implements PasswordUpgrader $this->getEntityManager()->persist($user); $this->getEntityManager()->flush(); } + + public function makeAdmin(string $email): void + { + $user = $this->findOneBy(['email' => $email]); + if (!$user instanceof User) { + throw new \InvalidArgumentException('User not found'); + } + + $user->setRoles(['ROLE_ADMIN']); + $this->getEntityManager()->flush(); + } } diff --git a/symfony.lock b/symfony.lock index cd2a560..5814c40 100644 --- a/symfony.lock +++ b/symfony.lock @@ -72,16 +72,16 @@ ] }, "phpunit/phpunit": { - "version": "11.5", + "version": "12.1", "recipe": { "repo": "github.com/symfony/recipes", "branch": "main", - "version": "9.6", - "ref": "7364a21d87e658eb363c5020c072ecfdc12e2326" + "version": "10.0", + "ref": "bb22cf8d8c554a623b427d5f3416b538f5525233" }, "files": [ ".env.test", - "phpunit.xml.dist", + "phpunit.dist.xml", "tests/bootstrap.php" ] }, @@ -174,6 +174,21 @@ "ref": "fadbfe33303a76e25cb63401050439aa9b1a9c7f" } }, + "symfony/phpunit-bridge": { + "version": "7.2", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "main", + "version": "6.3", + "ref": "a411a0480041243d97382cac7984f7dce7813c08" + }, + "files": [ + ".env.test", + "bin/phpunit", + "phpunit.xml.dist", + "tests/bootstrap.php" + ] + }, "symfony/routing": { "version": "7.2", "recipe": { diff --git a/templates/backoffice/base.html.twig b/templates/backoffice/base.html.twig index f29abf8..ab480e2 100644 --- a/templates/backoffice/base.html.twig +++ b/templates/backoffice/base.html.twig @@ -2,6 +2,7 @@ + + bootEnv(dirname(__DIR__).'/.env'); +if (method_exists(Dotenv::class, 'bootEnv')) { + (new Dotenv())->bootEnv(dirname(__DIR__).'/.env'); +} if ($_SERVER['APP_DEBUG']) { umask(0000);