From bf920b03d5227b15bfdabbe2587fd512d5bfbba1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jib=C3=A9=20Barth?= Date: Tue, 23 Dec 2025 16:08:00 +0100 Subject: [PATCH 1/5] Use sylius/test-application --- .github/workflows/analysis.yaml | 5 -- .github/workflows/sylius.yaml | 49 ++++++------ .gitignore | 4 + CONTRIBUTING.md | 10 +-- Makefile | 75 ++++--------------- assets/admin/entrypoint.js | 1 + assets/controllers.json | 2 + assets/shop/entrypoint.js | 1 + composer.json | 58 +++++++++++--- .../config/packages/mailtester.yaml | 2 - node_modules | 1 - phpspec.yml.dist | 4 - phpunit.xml.dist | 8 +- ruleset/.php_md.xml | 1 - ruleset/ecs.php | 1 - ruleset/phpstan.neon | 3 - spec/SynoliaSyliusMailTesterPluginSpec.php | 16 ---- tests/TestApplication/.env | 7 ++ tests/TestApplication/config/config.yaml | 22 ++++++ .../TestApplication/config/routing.yaml | 0 tests/TestApplication/public/.htaccess | 70 +++++++++++++++++ .../src/Form/Type/DummyFormType.php | 2 +- tests/app/config/packages/mailtester.yaml | 2 - .../config/packages/test/sylius_mailer.yaml | 7 -- 24 files changed, 202 insertions(+), 149 deletions(-) create mode 100644 assets/admin/entrypoint.js create mode 100644 assets/controllers.json create mode 100644 assets/shop/entrypoint.js delete mode 100644 install/Application/config/packages/mailtester.yaml delete mode 120000 node_modules delete mode 100644 phpspec.yml.dist delete mode 100644 spec/SynoliaSyliusMailTesterPluginSpec.php create mode 100644 tests/TestApplication/.env create mode 100644 tests/TestApplication/config/config.yaml rename install/Application/config/routes/sylius_mail_tester.yaml => tests/TestApplication/config/routing.yaml (100%) create mode 100644 tests/TestApplication/public/.htaccess rename tests/{data => TestApplication}/src/Form/Type/DummyFormType.php (93%) delete mode 100644 tests/app/config/packages/mailtester.yaml delete mode 100644 tests/data/config/packages/test/sylius_mailer.yaml diff --git a/.github/workflows/analysis.yaml b/.github/workflows/analysis.yaml index 7bdac1c..78b3a05 100644 --- a/.github/workflows/analysis.yaml +++ b/.github/workflows/analysis.yaml @@ -20,7 +20,6 @@ jobs: - 8.3 symfony: - '6.4.*' - - '7.2.*' env: APP_ENV: test steps: @@ -77,7 +76,3 @@ jobs: name: 'GrumPHP - Run' run: 'if [ -f grumphp.yml ]; then vendor/bin/grumphp run ; else echo Grumphp ruleset file does not exist, skipping step ; fi' if: 'always() && steps.end-of-setup.outcome == ''success''' - - - uses: symfonycorp/security-checker-action@v5 - if: 'always() && steps.end-of-setup.outcome == ''success''' - continue-on-error: true diff --git a/.github/workflows/sylius.yaml b/.github/workflows/sylius.yaml index 4ba909e..0027ef1 100644 --- a/.github/workflows/sylius.yaml +++ b/.github/workflows/sylius.yaml @@ -18,11 +18,13 @@ jobs: php: - 8.2 - 8.3 + - 8.4 sylius: - - 2.0.0 + - 2.1.0 + - 2.2.0 symfony: - 6.4 - - 7.2 + - 7.4 node: - 20.x env: @@ -77,48 +79,39 @@ jobs: restore-keys: "node-${{ matrix.node }}-yarn-\n" - name: 'Install Sylius-Standard and Plugin' - run: 'make install -e SYLIUS_VERSION=${{ matrix.sylius }} SYMFONY_VERSION=${{ matrix.symfony }} PHP_VERSION=${{ matrix.php }}' + run: 'make install -e SYLIUS_VERSION=${{ matrix.sylius }} SYMFONY_VERSION=${{ matrix.symfony }}' - name: 'Output PHP version for Symfony CLI' - working-directory: ./tests/Application run: 'php -v | head -n 1 | awk ''{ print $2 }'' > .php-version' - - - name: 'Install certificates' - working-directory: ./tests/Application - run: 'symfony server:ca:install' - name: 'Run Chrome headless' - working-directory: ./tests/Application run: 'google-chrome-stable --enable-automation --disable-background-networking --no-default-browser-check --no-first-run --disable-popup-blocking --disable-default-apps --allow-insecure-localhost --disable-translate --disable-extensions --no-sandbox --enable-features=Metal --headless --remote-debugging-port=9222 --window-size=2880,1800 --proxy-server=''direct://'' --proxy-bypass-list=''*'' https://127.0.0.1 > /dev/null 2>&1 &' - name: 'Run webserver' - working-directory: ./tests/Application - run: 'symfony server:start --port=8080 --dir=public --daemon' + run: 'symfony server:start --port=8080 -e test --daemon' id: end-of-setup-sylius - name: 'Doctrine Schema Validate - Run' - working-directory: ./tests/Application - run: 'php bin/console doctrine:schema:validate --skip-sync' + run: 'php vendor/bin/console doctrine:schema:validate --skip-sync' if: 'always() && steps.end-of-setup-sylius.outcome == ''success''' - name: 'Run PHPUnit' run: 'make phpunit' if: 'always() && steps.end-of-setup-sylius.outcome == ''success''' - - - name: 'Configure Behat' - run: 'make behat-configure' - if: 'always() && steps.end-of-setup-sylius.outcome == ''success''' - - - name: 'Run behat' - working-directory: ./tests/Application - run: 'vendor/bin/behat --strict --no-interaction -f progress || vendor/bin/behat --strict -vvv --no-interaction --rerun' - if: 'always() && steps.end-of-setup-sylius.outcome == ''success''' - - - uses: actions/upload-artifact@v4 - if: failure() - with: - name: logs - path: ./tests/Application/etc/build +# - +# name: 'Configure Behat' +# run: 'make behat-configure' +# if: 'always() && steps.end-of-setup-sylius.outcome == ''success''' +# - +# name: 'Run behat' +# run: 'vendor/bin/behat --strict --no-interaction -f progress || vendor/bin/behat --strict -vvv --no-interaction --rerun' +# if: 'always() && steps.end-of-setup-sylius.outcome == ''success''' +# - +# uses: actions/upload-artifact@v4 +# if: failure() +# with: +# name: logs +# path: ./etc/build services: mariadb: image: 'mariadb:10.4.11' diff --git a/.gitignore b/.gitignore index 1df3974..547af6c 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,7 @@ /.phpunit.result.cache /.idea/ + +/tests/TestApplication/.env.local +/tests/TestApplication/.env.*.local +/var/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 30b6106..62bd844 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -3,12 +3,12 @@ From the plugin root directory, run the following commands: ```bash -$ make install -e SYLIUS_VERSION=XX SYMFONY_VERSION=YY PHP_VERSION=ZZ +$ make install -e SYLIUS_VERSION=XX SYMFONY_VERSION=YY ``` -Default values : XX=2.0 and YY=7.1 and ZZ=8.3 +Default values : XX=2.1 and YY=6.4 -To be able to set up the plugin database, remember to configure you database credentials +To be able to set up the plugin database, remember to configure your database credentials in `install/Application/.env.local` and `install/Application/.env.test.local`. To reset test environment: @@ -39,11 +39,11 @@ $ make reset - Using `test` environment: ```bash - $ (cd tests/Application && bin/console server:run -d public -e test) + $ symfony server:start -d -e test ``` - Using `dev` environment: ```bash - $ (cd tests/Application && bin/console server:run -d public -e dev) + $ symfony server:start -d -e dev ``` diff --git a/Makefile b/Makefile index 3ad5233..bf7f9eb 100644 --- a/Makefile +++ b/Makefile @@ -1,87 +1,42 @@ .DEFAULT_GOAL := help SHELL=/bin/bash -COMPOSER_ROOT=composer -TEST_DIRECTORY=tests/Application -INSTALL_DIRECTORY=install/Application -CONSOLE=cd ${TEST_DIRECTORY} && php bin/console -e test -COMPOSER=cd ${TEST_DIRECTORY} && composer -YARN=cd ${TEST_DIRECTORY} && yarn - -SYLIUS_VERSION=2.0 -SYMFONY_VERSION=7.1 -PHP_VERSION=8.3 +CONSOLE=vendor/bin/console +COMPOSER=composer +SYLIUS_VERSION=2.1.0 +SYMFONY_VERSION=6.4 PLUGIN_NAME=synolia/sylius-mail-tester-plugin ### ### DEVELOPMENT ### ¯¯¯¯¯¯¯¯¯¯¯ -install: sylius ## Install Plugin on Sylius [SYLIUS_VERSION=1.12.0] [SYMFONY_VERSION=6.1] [PHP_VERSION=8.1] +install: sylius ## Install all dependencies with [SYLIUS_VERSION=2.1.0] [SYMFONY_VERSION=6.4] .PHONY: install reset: ## Remove dependencies -ifneq ("$(wildcard ${TEST_DIRECTORY}/bin/console)","") ${CONSOLE} doctrine:database:drop --force --if-exists || true -endif - rm -rf ${TEST_DIRECTORY} + rm -rf vendor + rm composer.lock .PHONY: reset -phpunit: phpunit-configure phpunit-run ## Run PHPUnit +phpunit: ## Run PHPUnit tests + ./vendor/bin/phpunit --testdox .PHONY: phpunit ### ### OTHER ### ¯¯¯¯¯¯ -sylius: sylius-standard update-dependencies install-plugin install-sylius +sylius: install-sylius .PHONY: sylius -sylius-standard: -ifeq ($(shell [[ $(SYLIUS_VERSION) == *dev ]] && echo true ),true) - ${COMPOSER_ROOT} create-project sylius/sylius-standard:${SYLIUS_VERSION} ${TEST_DIRECTORY} --no-install --no-scripts -else - ${COMPOSER_ROOT} create-project sylius/sylius-standard ${TEST_DIRECTORY} "~${SYLIUS_VERSION}" --no-install --no-scripts -endif - ${COMPOSER} config allow-plugins true -ifeq ($(shell [[ $(SYLIUS_VERSION) == *dev ]] && echo true ),true) - ${COMPOSER} require sylius/sylius:"${SYLIUS_VERSION}" -else - ${COMPOSER} require sylius/sylius:"~${SYLIUS_VERSION}" -endif - -update-dependencies: - ${COMPOSER} config extra.symfony.require "~${SYMFONY_VERSION}" - ${COMPOSER} require --dev donatj/mock-webserver:^2.1 --no-scripts --no-update - ${COMPOSER} require symfony/asset:~${SYMFONY_VERSION} --no-scripts --no-update - ${COMPOSER} update --no-progress -n - -install-plugin: - ${COMPOSER} config repositories.plugin '{"type": "path", "url": "../../"}' - ${COMPOSER} config extra.symfony.allow-contrib true - ${COMPOSER} config minimum-stability "dev" - ${COMPOSER} config prefer-stable true - ${COMPOSER} req ${PLUGIN_NAME}:* --prefer-source --no-scripts - cp -r ${INSTALL_DIRECTORY} tests - cp -r tests/data/* ${TEST_DIRECTORY}/ - install-sylius: - ${CONSOLE} sylius:install -n -s default - ${YARN} install - ${YARN} build - ${CONSOLE} cache:clear - -phpunit-configure: - cp phpunit.xml.dist ${TEST_DIRECTORY}/phpunit.xml - -phpunit-run: - cd ${TEST_DIRECTORY} && ./vendor/bin/phpunit + @echo "Installing Sylius ${SYLIUS_VERSION} using TestApplication" + ${COMPOSER} config extra.symfony.require "^${SYMFONY_VERSION}" + ${COMPOSER} install + ${COMPOSER} require --dev sylius/test-application:"~${SYLIUS_VERSION}@alpha" -n -W + ${COMPOSER} test-application:install -behat-configure: ## Configure Behat - (cd ${TEST_DIRECTORY} && cp behat.yml.dist behat.yml) - (cd ${TEST_DIRECTORY} && sed -i "s#vendor/sylius/sylius/src/Sylius/Behat/Resources/config/suites.yml#vendor/${PLUGIN_NAME}/tests/Behat/Resources/suites.yml#g" behat.yml) - (cd ${TEST_DIRECTORY} && sed -i "s#vendor/sylius/sylius/features#vendor/${PLUGIN_NAME}/features#g" behat.yml) - (cd ${TEST_DIRECTORY} && sed -i '2i \ \ \ \ - { resource: "../vendor/${PLUGIN_NAME}/tests/Behat/Resources/services.yaml" }' config/services_test.yaml) - ${CONSOLE} cache:clear grumphp: ## Run GrumPHP vendor/bin/grumphp run diff --git a/assets/admin/entrypoint.js b/assets/admin/entrypoint.js new file mode 100644 index 0000000..bbefcaa --- /dev/null +++ b/assets/admin/entrypoint.js @@ -0,0 +1 @@ +// Mandatory by test application but useless diff --git a/assets/controllers.json b/assets/controllers.json new file mode 100644 index 0000000..2c63c08 --- /dev/null +++ b/assets/controllers.json @@ -0,0 +1,2 @@ +{ +} diff --git a/assets/shop/entrypoint.js b/assets/shop/entrypoint.js new file mode 100644 index 0000000..bbefcaa --- /dev/null +++ b/assets/shop/entrypoint.js @@ -0,0 +1 @@ +// Mandatory by test application but useless diff --git a/composer.json b/composer.json index 8a6d585..54e42d4 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,6 @@ "friends-of-behat/symfony-extension": "2.6.0", "friends-of-behat/variadic-extension": "1.6.0", "friendsoftwig/twigcs": "6.4.0", - "j13k/yaml-lint": "1.1.6", "php-parallel-lint/php-parallel-lint": "1.4.0", "phpmd/phpmd": "2.15.0", "phpro/grumphp": "2.11.0", @@ -46,17 +45,22 @@ "seld/jsonlint": "1.11.0", "squizlabs/php_codesniffer": "3.11.3", "sylius-labs/coding-standard": "4.4.0", - "symfony/browser-kit": "7.2.4", - "symfony/debug-bundle": "^7.2.0", - "symfony/dotenv": "7.2.0", - "symfony/lock": "7.2.4", - "symfony/web-profiler-bundle": "7.2.4" + "sylius/test-application": "~2.1.0@alpha", + "symfony/browser-kit": "^6.4 | ^7.4 | ^8.0", + "symfony/debug-bundle": "^6.4 | ^7.4 | ^8.0", + "symfony/dotenv": "^6.4 | ^7.4 | ^8.0", + "symfony/lock": "^6.4 | ^7.4 | ^8.0", + "symfony/web-profiler-bundle": "^6.4 | ^7.4 | ^8.0" }, "prefer-stable": true, "autoload": { "psr-4": { - "Synolia\\SyliusMailTesterPlugin\\": "src/", - "Tests\\Synolia\\SyliusMailTesterPlugin\\": "tests/" + "Synolia\\SyliusMailTesterPlugin\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "Tests\\Synolia\\SyliusMailTesterPlugin\\": ["tests/", "tests/TestApplication/src/"] } }, "config": { @@ -66,10 +70,46 @@ "php-http/discovery": true, "phpro/grumphp": true, "phpstan/extension-installer": true, + "symfony/flex": true, + "symfony/runtime": true, "symfony/thanks": true } }, "scripts": { - "fix-ecs": "ecs check -c ruleset/ecs.php --fix --ansi --clear-cache ." + "ecs": "ecs check -c ruleset/ecs.php --ansi --clear-cache", + "fix-ecs": "@ecs --fix", + "phpmd": "phpmd src ansi ruleset/.php_md.xml", + "phpstan": "phpstan analyse src -c ruleset/phpstan.neon", + "phpunit": "phpunit tests/PHPUnit --colors=always", + "tests": [ + "@ecs", + "@phpmd", + "@phpstan", + "@phpunit" + ], + "test-application:install": [ + "vendor/bin/console doctrine:database:drop --force --if-exists -n", + "vendor/bin/console doctrine:database:create -n", + "vendor/bin/console doctrine:migration:migrate -n", + "vendor/bin/console sylius:payment:generate-key -n", + "vendor/bin/console sylius:fixtures:load -n", + "yarn --cwd vendor/sylius/test-application install --force", + "yarn --cwd vendor/sylius/test-application build", + "vendor/bin/console assets:install --symlink -n vendor/sylius/test-application/public", + "cp tests/TestApplication/public/.htaccess vendor/sylius/test-application/public" + ], + "test-application:front": [ + "yarn --cwd vendor/sylius/test-application install --force", + "yarn --cwd vendor/sylius/test-application build" + ] + }, + "extra": { + "public-dir": "vendor/sylius/test-application/public", + "symfony": { + "require": "^6.4" + } + }, + "conflict": { + "sylius/test-application": "v2.0.0-ALPHA.1" } } diff --git a/install/Application/config/packages/mailtester.yaml b/install/Application/config/packages/mailtester.yaml deleted file mode 100644 index 90562f5..0000000 --- a/install/Application/config/packages/mailtester.yaml +++ /dev/null @@ -1,2 +0,0 @@ -imports: - - { resource: "@SynoliaSyliusMailTesterPlugin/config/config.yaml" } \ No newline at end of file diff --git a/node_modules b/node_modules deleted file mode 120000 index 9270531..0000000 --- a/node_modules +++ /dev/null @@ -1 +0,0 @@ -tests/Application/node_modules \ No newline at end of file diff --git a/phpspec.yml.dist b/phpspec.yml.dist deleted file mode 100644 index 9142a14..0000000 --- a/phpspec.yml.dist +++ /dev/null @@ -1,4 +0,0 @@ -suites: - main: - namespace: Synolia\SyliusMailTesterPlugin - psr4_prefix: Synolia\SyliusMailTesterPlugin diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 289c057..3c68779 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,19 +1,19 @@ + bootstrap="vendor/sylius/test-application/config/bootstrap.php"> - vendor/synolia/sylius-mail-tester-plugin/tests/PHPUnit + tests/PHPUnit - + diff --git a/ruleset/.php_md.xml b/ruleset/.php_md.xml index 3de7b13..266cdf5 100644 --- a/ruleset/.php_md.xml +++ b/ruleset/.php_md.xml @@ -48,6 +48,5 @@ src/Migrations/* - spec/* tests/* diff --git a/ruleset/ecs.php b/ruleset/ecs.php index 7194a38..e04473d 100644 --- a/ruleset/ecs.php +++ b/ruleset/ecs.php @@ -11,7 +11,6 @@ dirname(__DIR__, 1) . '/src', dirname(__DIR__, 1) . '/tests/Behat', dirname(__DIR__, 1) . '/tests/PHPUnit', - dirname(__DIR__, 1) . '/spec', ]); /** @phpstan-ignore-next-line */ diff --git a/ruleset/phpstan.neon b/ruleset/phpstan.neon index c7dbe49..184d8a3 100644 --- a/ruleset/phpstan.neon +++ b/ruleset/phpstan.neon @@ -7,9 +7,6 @@ parameters: # Makes PHPStan crash - ../src/Form/Type/Plugin/InvoicingPlugin/InvoiceType.php - # PHPSpec - - ../spec - ignoreErrors: - identifier: missingType.iterableValue - identifier: missingType.generics diff --git a/spec/SynoliaSyliusMailTesterPluginSpec.php b/spec/SynoliaSyliusMailTesterPluginSpec.php deleted file mode 100644 index 5941236..0000000 --- a/spec/SynoliaSyliusMailTesterPluginSpec.php +++ /dev/null @@ -1,16 +0,0 @@ -shouldHaveType(SynoliaSyliusMailTesterPlugin::class); - } -} diff --git a/tests/TestApplication/.env b/tests/TestApplication/.env new file mode 100644 index 0000000..d112aea --- /dev/null +++ b/tests/TestApplication/.env @@ -0,0 +1,7 @@ +DATABASE_URL=mysql://root@127.0.0.1/test_application_%kernel.environment% + +SYLIUS_TEST_APP_CONFIGS_TO_IMPORT="@SynoliaSyliusMailTesterPlugin/tests/TestApplication/config/config.yaml" +SYLIUS_TEST_APP_ROUTES_TO_IMPORT="@SynoliaSyliusMailTesterPlugin/tests/TestApplication/config/routing.yaml" +SYLIUS_TEST_APP_BUNDLES_TO_ENABLE="Synolia\SyliusMailTesterPlugin\SynoliaSyliusMailTesterPlugin" + +SYLIUS_MESSENGER_TRANSPORT_PAYMENT_REQUEST_DSN="sync://" diff --git a/tests/TestApplication/config/config.yaml b/tests/TestApplication/config/config.yaml new file mode 100644 index 0000000..c70c48f --- /dev/null +++ b/tests/TestApplication/config/config.yaml @@ -0,0 +1,22 @@ +imports: + - { resource: "@SynoliaSyliusMailTesterPlugin/config/config.yaml" } + +# Uncomment if need to override entities with trait for example +#doctrine: +# orm: +# entity_managers: +# default: +# mappings: +# TestApplication: +# is_bundle: false +# type: attribute +# dir: '%kernel.project_dir%/../../../tests/TestApplication/src/Entity' +# prefix: Tests\Synolia\SyliusMailTesterPlugin + +sylius_mailer: + emails: + verification_token: + enabled: false + my_dummy_form_type: + subject: dummy.test + template: "@SyliusCore/Email/contactRequest.html.twig" diff --git a/install/Application/config/routes/sylius_mail_tester.yaml b/tests/TestApplication/config/routing.yaml similarity index 100% rename from install/Application/config/routes/sylius_mail_tester.yaml rename to tests/TestApplication/config/routing.yaml diff --git a/tests/TestApplication/public/.htaccess b/tests/TestApplication/public/.htaccess new file mode 100644 index 0000000..082060e --- /dev/null +++ b/tests/TestApplication/public/.htaccess @@ -0,0 +1,70 @@ +# Use the front controller as index file. It serves as a fallback solution when +# every other rewrite/redirect fails (e.g. in an aliased environment without +# mod_rewrite). Additionally, this reduces the matching process for the +# start page (path "/") because otherwise Apache will apply the rewriting rules +# to each configured DirectoryIndex file (e.g. index.php, index.html, index.pl). +DirectoryIndex index.php + +# By default, Apache does not evaluate symbolic links if you did not enable this +# feature in your server configuration. Uncomment the following line if you +# install assets as symlinks or if you experience problems related to symlinks +# when compiling LESS/Sass/CoffeScript assets. +# Options +SymLinksIfOwnerMatch + +# Disabling MultiViews prevents unwanted negotiation, e.g. "/index" should not resolve +# to the front controller "/index.php" but be rewritten to "/index.php/index". + + Options -MultiViews + + + + # This Option needs to be enabled for RewriteRule, otherwise it will show an error like + # 'Options FollowSymLinks or SymLinksIfOwnerMatch is off which implies that RewriteRule directive is forbidden' + Options +SymLinksIfOwnerMatch + + RewriteEngine On + + # Determine the RewriteBase automatically and set it as environment variable. + # If you are using Apache aliases to do mass virtual hosting or installed the + # project in a subdirectory, the base path will be prepended to allow proper + # resolution of the index.php file and to redirect to the correct URI. It will + # work in environments without path prefix as well, providing a safe, one-size + # fits all solution. But as you do not need it in this case, you can comment + # the following 2 lines to eliminate the overhead. + RewriteCond %{REQUEST_URI}::$0 ^(/.+)/(.*)::\2$ + RewriteRule .* - [E=BASE:%1] + + # Sets the HTTP_AUTHORIZATION header removed by Apache + RewriteCond %{HTTP:Authorization} .+ + RewriteRule ^ - [E=HTTP_AUTHORIZATION:%0] + + # Redirect to URI without front controller to prevent duplicate content + # (with and without `/index.php`). Only do this redirect on the initial + # rewrite by Apache and not on subsequent cycles. Otherwise we would get an + # endless redirect loop (request -> rewrite to front controller -> + # redirect -> request -> ...). + # So in case you get a "too many redirects" error or you always get redirected + # to the start page because your Apache does not expose the REDIRECT_STATUS + # environment variable, you have 2 choices: + # - disable this feature by commenting the following 2 lines or + # - use Apache >= 2.3.9 and replace all L flags by END flags and remove the + # following RewriteCond (best solution) + RewriteCond %{ENV:REDIRECT_STATUS} ="" + RewriteRule ^index\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=308,L] + + # If the requested filename exists, simply serve it. + # We only want to let Apache serve files and not directories. + # Rewrite all other queries to the front controller. + RewriteCond %{REQUEST_FILENAME} !-f + RewriteRule ^ %{ENV:BASE}/index.php [L] + + + + + # When mod_rewrite is not available, we instruct a temporary redirect of + # the start page to the front controller explicitly so that the website + # and the generated links can still be used. + RedirectMatch 307 ^/$ /index.php/ + # RedirectTemp cannot be used instead + + diff --git a/tests/data/src/Form/Type/DummyFormType.php b/tests/TestApplication/src/Form/Type/DummyFormType.php similarity index 93% rename from tests/data/src/Form/Type/DummyFormType.php rename to tests/TestApplication/src/Form/Type/DummyFormType.php index 9e74b1d..055bae6 100644 --- a/tests/data/src/Form/Type/DummyFormType.php +++ b/tests/TestApplication/src/Form/Type/DummyFormType.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Form\Type; +namespace Tests\Synolia\SyliusMailTesterPlugin\Form\Type; use Symfony\Component\Form\Extension\Core\Type\EmailType; use Symfony\Component\Form\Extension\Core\Type\FormType; diff --git a/tests/app/config/packages/mailtester.yaml b/tests/app/config/packages/mailtester.yaml deleted file mode 100644 index 90562f5..0000000 --- a/tests/app/config/packages/mailtester.yaml +++ /dev/null @@ -1,2 +0,0 @@ -imports: - - { resource: "@SynoliaSyliusMailTesterPlugin/config/config.yaml" } \ No newline at end of file diff --git a/tests/data/config/packages/test/sylius_mailer.yaml b/tests/data/config/packages/test/sylius_mailer.yaml deleted file mode 100644 index 105c8eb..0000000 --- a/tests/data/config/packages/test/sylius_mailer.yaml +++ /dev/null @@ -1,7 +0,0 @@ -sylius_mailer: - emails: - verification_token: - enabled: false - my_dummy_form_type: - subject: dummy.test - template: "@SyliusCore/Email/contactRequest.html.twig" From 7806c2fdb30e4ea922b2fb89afc0c8166f38636b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jib=C3=A9=20Barth?= Date: Tue, 23 Dec 2025 16:16:22 +0100 Subject: [PATCH 2/5] Fix declare new service in tests --- tests/TestApplication/config/config.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/TestApplication/config/config.yaml b/tests/TestApplication/config/config.yaml index c70c48f..10e7c60 100644 --- a/tests/TestApplication/config/config.yaml +++ b/tests/TestApplication/config/config.yaml @@ -20,3 +20,11 @@ sylius_mailer: my_dummy_form_type: subject: dummy.test template: "@SyliusCore/Email/contactRequest.html.twig" + +services: + _defaults: + autowire: true + autoconfigure: true + + Tests\Synolia\SyliusMailTesterPlugin\: + resource: '../src/*' From 6ae1a3a3cd621f7f93981faf029f68b8a522c334 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jib=C3=A9=20Barth?= Date: Tue, 23 Dec 2025 16:25:59 +0100 Subject: [PATCH 3/5] Bump TwigCS, drop phpspec --- composer.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 54e42d4..9982e0c 100644 --- a/composer.json +++ b/composer.json @@ -28,11 +28,10 @@ "friends-of-behat/page-object-extension": "0.3.2", "friends-of-behat/symfony-extension": "2.6.0", "friends-of-behat/variadic-extension": "1.6.0", - "friendsoftwig/twigcs": "6.4.0", + "friendsoftwig/twigcs": "6.6.0", "php-parallel-lint/php-parallel-lint": "1.4.0", "phpmd/phpmd": "2.15.0", "phpro/grumphp": "2.11.0", - "phpspec/phpspec": "7.5.0", "phpstan/extension-installer": "1.4.3", "phpstan/phpstan": "2.1.8", "phpstan/phpstan-doctrine": "2.0.2", From b5a0076470e07f03ac81306aa0ef94f692990a76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jib=C3=A9=20Barth?= Date: Tue, 23 Dec 2025 16:33:55 +0100 Subject: [PATCH 4/5] Fix starting symfony server --- .github/workflows/sylius.yaml | 2 +- CONTRIBUTING.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/sylius.yaml b/.github/workflows/sylius.yaml index 0027ef1..ac055a4 100644 --- a/.github/workflows/sylius.yaml +++ b/.github/workflows/sylius.yaml @@ -88,7 +88,7 @@ jobs: run: 'google-chrome-stable --enable-automation --disable-background-networking --no-default-browser-check --no-first-run --disable-popup-blocking --disable-default-apps --allow-insecure-localhost --disable-translate --disable-extensions --no-sandbox --enable-features=Metal --headless --remote-debugging-port=9222 --window-size=2880,1800 --proxy-server=''direct://'' --proxy-bypass-list=''*'' https://127.0.0.1 > /dev/null 2>&1 &' - name: 'Run webserver' - run: 'symfony server:start --port=8080 -e test --daemon' + run: 'APP_ENV=test symfony server:start --port=8080 --daemon' id: end-of-setup-sylius - name: 'Doctrine Schema Validate - Run' diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 62bd844..7c10afb 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -39,11 +39,11 @@ $ make reset - Using `test` environment: ```bash - $ symfony server:start -d -e test + $ APP_ENV=test symfony server:start -d ``` - Using `dev` environment: ```bash - $ symfony server:start -d -e dev + $ symfony server:start -d ``` From a0109425067e2156ae76d400596703ed34e36fb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jib=C3=A9=20Barth?= Date: Tue, 23 Dec 2025 16:57:33 +0100 Subject: [PATCH 5/5] Drop Behat --- .github/workflows/analysis.yaml | 2 +- .github/workflows/sylius.yaml | 25 +-- behat.yml.dist | 61 ------- composer.json | 11 -- etc/build/.gitignore | 0 .../ui/admin/change_form_by_subjects.feature | 16 -- .../ui/admin/check_mail_tester_fields.feature | 16 -- features/ui/admin/send_email.feature | 28 --- .../ui/admin/send_every_mails_in_one.feature | 24 --- ruleset/ecs.php | 1 - .../Context/Ui/Admin/MailTesterContext.php | 172 ------------------ .../Behat/Page/Admin/MailTester/IndexPage.php | 70 ------- .../Admin/MailTester/IndexPageInterface.php | 24 --- tests/Behat/Resources/services.yaml | 16 -- tests/Behat/Resources/suites.yml | 10 - 15 files changed, 2 insertions(+), 474 deletions(-) delete mode 100644 behat.yml.dist delete mode 100644 etc/build/.gitignore delete mode 100644 features/ui/admin/change_form_by_subjects.feature delete mode 100644 features/ui/admin/check_mail_tester_fields.feature delete mode 100644 features/ui/admin/send_email.feature delete mode 100644 features/ui/admin/send_every_mails_in_one.feature delete mode 100644 tests/Behat/Context/Ui/Admin/MailTesterContext.php delete mode 100644 tests/Behat/Page/Admin/MailTester/IndexPage.php delete mode 100644 tests/Behat/Page/Admin/MailTester/IndexPageInterface.php delete mode 100644 tests/Behat/Resources/services.yaml delete mode 100644 tests/Behat/Resources/suites.yml diff --git a/.github/workflows/analysis.yaml b/.github/workflows/analysis.yaml index 78b3a05..89d1da7 100644 --- a/.github/workflows/analysis.yaml +++ b/.github/workflows/analysis.yaml @@ -58,7 +58,7 @@ jobs: id: end-of-setup - name: 'ECS - Run' - run: 'if [ -f ruleset/ecs.php ]; then vendor/bin/ecs check src/ tests/Behat/ --no-progress-bar -c ruleset/ecs.php ; else echo Ecs ruleset file does not exist, skipping step ; fi' + run: 'if [ -f ruleset/ecs.php ]; then vendor/bin/ecs check src/ --no-progress-bar -c ruleset/ecs.php ; else echo Ecs ruleset file does not exist, skipping step ; fi' if: 'always() && steps.end-of-setup.outcome == ''success''' - name: 'PHPStan - Run' diff --git a/.github/workflows/sylius.yaml b/.github/workflows/sylius.yaml index ac055a4..319cbd3 100644 --- a/.github/workflows/sylius.yaml +++ b/.github/workflows/sylius.yaml @@ -80,16 +80,6 @@ jobs: - name: 'Install Sylius-Standard and Plugin' run: 'make install -e SYLIUS_VERSION=${{ matrix.sylius }} SYMFONY_VERSION=${{ matrix.symfony }}' - - - name: 'Output PHP version for Symfony CLI' - run: 'php -v | head -n 1 | awk ''{ print $2 }'' > .php-version' - - - name: 'Run Chrome headless' - run: 'google-chrome-stable --enable-automation --disable-background-networking --no-default-browser-check --no-first-run --disable-popup-blocking --disable-default-apps --allow-insecure-localhost --disable-translate --disable-extensions --no-sandbox --enable-features=Metal --headless --remote-debugging-port=9222 --window-size=2880,1800 --proxy-server=''direct://'' --proxy-bypass-list=''*'' https://127.0.0.1 > /dev/null 2>&1 &' - - - name: 'Run webserver' - run: 'APP_ENV=test symfony server:start --port=8080 --daemon' - id: end-of-setup-sylius - name: 'Doctrine Schema Validate - Run' run: 'php vendor/bin/console doctrine:schema:validate --skip-sync' @@ -98,20 +88,7 @@ jobs: name: 'Run PHPUnit' run: 'make phpunit' if: 'always() && steps.end-of-setup-sylius.outcome == ''success''' -# - -# name: 'Configure Behat' -# run: 'make behat-configure' -# if: 'always() && steps.end-of-setup-sylius.outcome == ''success''' -# - -# name: 'Run behat' -# run: 'vendor/bin/behat --strict --no-interaction -f progress || vendor/bin/behat --strict -vvv --no-interaction --rerun' -# if: 'always() && steps.end-of-setup-sylius.outcome == ''success''' -# - -# uses: actions/upload-artifact@v4 -# if: failure() -# with: -# name: logs -# path: ./etc/build + services: mariadb: image: 'mariadb:10.4.11' diff --git a/behat.yml.dist b/behat.yml.dist deleted file mode 100644 index e95062e..0000000 --- a/behat.yml.dist +++ /dev/null @@ -1,61 +0,0 @@ -imports: - - vendor/sylius/sylius/src/Sylius/Behat/Resources/config/suites.yml - - tests/Behat/Resources/suites.yml - -default: - formatters: - pretty: - verbose: true - paths: false - snippets: false - - extensions: - DMore\ChromeExtension\Behat\ServiceContainer\ChromeExtension: ~ - - FriendsOfBehat\MinkDebugExtension: - directory: etc/build - clean_start: false - screenshot: true - - Behat\MinkExtension: - files_path: "%paths.base%/vendor/sylius/sylius/src/Sylius/Behat/Resources/fixtures/" - base_url: "http://localhost:8080/" - default_session: symfony - javascript_session: chrome - sessions: - symfony: - symfony: ~ - chrome: - selenium2: - browser: chrome - capabilities: - browserName: chrome - browser: chrome - version: "" - marionette: null # https://github.com/Behat/MinkExtension/pull/311 - chrome: - switches: - - "start-fullscreen" - - "start-maximized" - - "no-sandbox" - extra_capabilities: - acceptSslCerts: true - acceptInsecureCerts: true - unexpectedAlertBehaviour: accept - goog:chromeOptions: - w3c: false # https://github.com/Sylius/Sylius/issues/10561 - firefox: - selenium2: - browser: firefox - show_auto: false - - FriendsOfBehat\SymfonyExtension: - bootstrap: tests/Application/config/bootstrap.php - kernel: - class: Tests\Synolia\SyliusMailTesterPlugin\Application\Kernel - - FriendsOfBehat\VariadicExtension: ~ - - gherkin: - filters: - tags: "~@todo&&~@cli" # CLI is excluded as it registers an error handler that mutes fatal errors diff --git a/composer.json b/composer.json index 9982e0c..3e2d3e8 100644 --- a/composer.json +++ b/composer.json @@ -17,17 +17,6 @@ "webmozart/assert": "^1.11" }, "require-dev": { - "behat/behat": "3.19.0", - "behat/mink-selenium2-driver": "1.7.0", - "dmore/behat-chrome-extension": "1.4.0", - "dmore/chrome-mink-driver": "2.9.3", - "friends-of-behat/mink": "1.11.0", - "friends-of-behat/mink-browserkit-driver": "1.6.2", - "friends-of-behat/mink-debug-extension": "2.1.0", - "friends-of-behat/mink-extension": "2.7.5", - "friends-of-behat/page-object-extension": "0.3.2", - "friends-of-behat/symfony-extension": "2.6.0", - "friends-of-behat/variadic-extension": "1.6.0", "friendsoftwig/twigcs": "6.6.0", "php-parallel-lint/php-parallel-lint": "1.4.0", "phpmd/phpmd": "2.15.0", diff --git a/etc/build/.gitignore b/etc/build/.gitignore deleted file mode 100644 index e69de29..0000000 diff --git a/features/ui/admin/change_form_by_subjects.feature b/features/ui/admin/change_form_by_subjects.feature deleted file mode 100644 index 96d3775..0000000 --- a/features/ui/admin/change_form_by_subjects.feature +++ /dev/null @@ -1,16 +0,0 @@ -@managing_mail_tester -Feature: Change form by subjects - In order to get the proper form for the subject - As an Administrator - I want to get the proper form for the subject - - Background: - Given I am logged in as an administrator - - @ui - Scenario: Change subjects to get their form - When I go to the mail tester page - Then I choose the subject contact_request - And I submit the subject - And the subject chosen in the form should be contact_request - Then the mail tester field "mail_tester[form_subject_chosen][data][email]" should be empty \ No newline at end of file diff --git a/features/ui/admin/check_mail_tester_fields.feature b/features/ui/admin/check_mail_tester_fields.feature deleted file mode 100644 index 38be23b..0000000 --- a/features/ui/admin/check_mail_tester_fields.feature +++ /dev/null @@ -1,16 +0,0 @@ -@managing_mail_tester -Feature: Check mail tester fields - In order to have every mail tester field - As an Administrator - I want to have every mail tester field - - Background: - Given I am logged in as an administrator - - @ui - Scenario: Check the recipient field - When I go to the mail tester page - Then the mail tester field "mail_tester[recipient]" should be empty - Then I write test in the field "mail_tester[recipient]" - Then the mail tester field "mail_tester[recipient]" should have test as value - Then the subjects should have every subjects \ No newline at end of file diff --git a/features/ui/admin/send_email.feature b/features/ui/admin/send_email.feature deleted file mode 100644 index 8d56eba..0000000 --- a/features/ui/admin/send_email.feature +++ /dev/null @@ -1,28 +0,0 @@ -@managing_mail_tester -Feature: Send an email - In order to send an email - As an Administrator - I want to send an email - - Background: - Given I am logged in as an administrator - - @ui - Scenario: Send contact_request mail - When I go to the mail tester page - Then I choose the subject contact_request - And I submit the subject - Then I write "test@test.com" in the field "mail_tester[recipient]" - And I write "test" in the field "mail_tester[form_subject_chosen][data][message]" - And I write "test@test.com" in the field "mail_tester[form_subject_chosen][data][email]" - Then I submit the email - And the email has been successfully send - - @ui - Scenario: Send order_confirmation mail - When I go to the mail tester page - Then I choose the subject order_confirmation - And I submit the subject - Then I write "test@test.com" in the field "mail_tester[recipient]" - Then I submit the email - And the email has been successfully send \ No newline at end of file diff --git a/features/ui/admin/send_every_mails_in_one.feature b/features/ui/admin/send_every_mails_in_one.feature deleted file mode 100644 index 3a5d75a..0000000 --- a/features/ui/admin/send_every_mails_in_one.feature +++ /dev/null @@ -1,24 +0,0 @@ -@managing_mail_tester -Feature: Send every mails in one form - In order to every mails - As an Administrator - I want to every mails in one form - - Background: - Given I am logged in as an administrator - - @ui - Scenario: Send every mails in one form - When I go to the mail tester page - Then I choose the subject every_subjects - And I submit the subject - Then I write "test@test.com" in the field "mail_tester[recipient]" - And I write "test@test.com" in the field "mail_tester[contact_request][data][email]" - And I write "test" in the field "mail_tester[contact_request][data][message]" - And I write "test@test.com" in the field "mail_tester[my_dummy_form_type][data][email]" - And I write "test" in the field "mail_tester[my_dummy_form_type][data][message]" - And change value for "shop@example.com" in select "mail_tester[password_reset][user]" - And change value for "shop@example.com" in select "mail_tester[user_registration][user]" - And change value for "shop@example.com" in select "mail_tester[verification_token][user]" - Then I submit the email - And the email has been successfully send diff --git a/ruleset/ecs.php b/ruleset/ecs.php index e04473d..36eeea7 100644 --- a/ruleset/ecs.php +++ b/ruleset/ecs.php @@ -9,7 +9,6 @@ $ecsConfig->paths([ dirname(__DIR__, 1) . '/src', - dirname(__DIR__, 1) . '/tests/Behat', dirname(__DIR__, 1) . '/tests/PHPUnit', ]); diff --git a/tests/Behat/Context/Ui/Admin/MailTesterContext.php b/tests/Behat/Context/Ui/Admin/MailTesterContext.php deleted file mode 100644 index ac057d6..0000000 --- a/tests/Behat/Context/Ui/Admin/MailTesterContext.php +++ /dev/null @@ -1,172 +0,0 @@ -currentPageResolver->getCurrentPageWithForm([ - $this->indexPage, - ]); - } - - /** - * @When I go to the mail tester page - */ - public function iGoToTheMailTesterPage(): void - { - $this->indexPage->open(); - } - - /** - * @Then the mail tester field :field should be empty - */ - public function theMailTesterFieldShouldBeEmpty(string $field): void - { - /** @var IndexPageInterface $currentPage */ - $currentPage = $this->resolveCurrentPage(); - Assert::isEmpty($currentPage->getFieldValue($field)); - } - - /** - * @Then I choose the subject :subject - */ - public function iChooseTheSubject(string $subject): void - { - /** @var IndexPageInterface $currentPage */ - $currentPage = $this->resolveCurrentPage(); - /** @var NodeElement|null $mailTesterSubject */ - $mailTesterSubject = $currentPage->writeInField($subject, 'mail_tester[subjects]'); - $mailTesterSubjectValue = ''; - if ($mailTesterSubject !== null) { - /** @var string $mailTesterSubjectValue */ - $mailTesterSubjectValue = $mailTesterSubject->getValue(); - } - Assert::contains($subject, $mailTesterSubjectValue); - } - - /** - * @Then the subject chosen in the form should be :subject - */ - public function theSubjectChooseInTheFormShouldBe(string $subject): void - { - /** @var IndexPageInterface $currentPage */ - $currentPage = $this->resolveCurrentPage(); - $mailTesterSubjectValue = $currentPage->getFieldValue('mail_tester[subjects]'); - Assert::eq($subject, $mailTesterSubjectValue); - } - - /** - * @Then I submit the subject - */ - public function iSubmitTheSubject(): void - { - /** @var IndexPageInterface $currentPage */ - $currentPage = $this->resolveCurrentPage(); - $currentPage->pressButton('mail_tester[change_form_subject]'); - } - - /** - * @Then I submit the email - */ - public function iSubmitTheEmail(): void - { - /** @var IndexPageInterface $currentPage */ - $currentPage = $this->resolveCurrentPage(); - $currentPage->pressButton('mail_tester[submit]'); - } - - /** - * @Then the mail tester field :field should not be empty - */ - public function theMailTesterFieldShouldNotBeEmpty(string $field): void - { - /** @var IndexPageInterface $currentPage */ - $currentPage = $this->resolveCurrentPage(); - Assert::notEmpty($currentPage->getFieldValue($field)); - } - - /** - * @Then I write :text in the field :field - */ - public function iWriteInTheField(string $text, string $field): void - { - /** @var IndexPageInterface $currentPage */ - $currentPage = $this->resolveCurrentPage(); - $currentPage->writeInField($text, $field); - } - - /** - * @Then change value for :value in select :select - */ - public function changeValueForInSelect(string $value, string $select): void - { - /** @var IndexPageInterface $currentPage */ - $currentPage = $this->resolveCurrentPage(); - $currentPage->changeSelectValue($value, $select); - } - - /** - * @Then the mail tester field :field should have :text as value - */ - public function theMailTesterFiledShouldHaveAsValue(string $field, string $text): void - { - /** @var IndexPageInterface $currentPage */ - $currentPage = $this->resolveCurrentPage(); - $fieldValue = $currentPage->getFieldValue($field); - Assert::string($fieldValue); - Assert::contains($fieldValue, $text); - } - - /** - * @Then the subjects should have every subjects - */ - public function theSubjectsShouldHaveEverySubjects(): void - { - /** @var IndexPageInterface $currentPage */ - $currentPage = $this->resolveCurrentPage(); - foreach ($this->emailKeysDataRetriever->getEmailKeys() as $emailKey) { - Assert::contains($currentPage->getSelectorHtml('mail_tester[subjects]'), $emailKey); - } - } - - /** - * @Then the email has been successfully send - */ - public function theEmailHasBeenSuccessfullySend(): void - { - $this->notificationChecker->checkNotification( - $this->translator->trans('sylius.ui.admin.mail_tester.success'), - NotificationType::success(), - ); - } -} diff --git a/tests/Behat/Page/Admin/MailTester/IndexPage.php b/tests/Behat/Page/Admin/MailTester/IndexPage.php deleted file mode 100644 index f34a7c6..0000000 --- a/tests/Behat/Page/Admin/MailTester/IndexPage.php +++ /dev/null @@ -1,70 +0,0 @@ -getDocument()->findField($field); - } - - /** @return string|bool|array */ - public function getFieldValue(string $field) - { - $field = $this->getDocument()->findField($field); - if ($field === null) { - return ''; - } - - /** @var string|bool|array|null $value */ - $value = $field->getValue(); - if ($value === null) { - return ''; - } - - return $value; - } - - public function getSelectorHtml(string $field): string - { - $field = $this->getDocument()->findField($field); - if ($field === null) { - return ''; - } - - return $field->getOuterHtml(); - } - - public function writeInField(string $text, string $field): ?NodeElement - { - $field = $this->getDocument()->findField($field); - if ($field === null) { - return null; - } - - $field->setValue($text); - - return $field; - } - - public function changeSelectValue(string $value, string $select): void - { - $field = $this->getDocument()->findField($select); - if ($field === null) { - return; - } - - $field->selectOption($value); - } - - public function pressButton(string $field): void - { - $this->getDocument()->pressButton($field); - } -} diff --git a/tests/Behat/Page/Admin/MailTester/IndexPageInterface.php b/tests/Behat/Page/Admin/MailTester/IndexPageInterface.php deleted file mode 100644 index 07253dd..0000000 --- a/tests/Behat/Page/Admin/MailTester/IndexPageInterface.php +++ /dev/null @@ -1,24 +0,0 @@ -