diff --git a/.github/workflows/analysis.yaml b/.github/workflows/analysis.yaml index 7bdac1c..89d1da7 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: @@ -59,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' @@ -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..319cbd3 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,16 @@ 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 }}' - - - 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' - id: end-of-setup-sylius + run: 'make install -e SYLIUS_VERSION=${{ matrix.sylius }} SYMFONY_VERSION=${{ matrix.symfony }}' - 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 + 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..7c10afb 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) + $ APP_ENV=test symfony server:start -d ``` - Using `dev` environment: ```bash - $ (cd tests/Application && bin/console server:run -d public -e dev) + $ symfony server:start -d ``` 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/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 8a6d585..3e2d3e8 100644 --- a/composer.json +++ b/composer.json @@ -17,23 +17,10 @@ "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.4.0", - "j13k/yaml-lint": "1.1.6", + "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", @@ -46,17 +33,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 +58,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/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/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..36eeea7 100644 --- a/ruleset/ecs.php +++ b/ruleset/ecs.php @@ -9,9 +9,7 @@ $ecsConfig->paths([ 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/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 @@ - + 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"