From cca5d01b85481d24ebc13f1aab1ec29755f901d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jib=C3=A9=20Barth?= Date: Mon, 21 Jul 2025 11:44:38 +0200 Subject: [PATCH 1/8] [Tests] Initialize TestApplication --- .gitignore | 4 + assets/controllers.json | 41 +++++++++ composer.json | 47 +++++++--- tests/TestApplication/.env | 5 ++ tests/TestApplication/config/bundles.php | 8 ++ tests/TestApplication/config/config.yaml | 87 +++++++++++++++++++ tests/TestApplication/config/routing.yaml | 5 ++ tests/TestApplication/package.json | 5 ++ tests/TestApplication/src/Entity/Customer.php | 16 ++++ tests/TestApplication/src/Entity/Payment.php | 23 +++++ .../src/Entity/PaymentMethod.php | 30 +++++++ 11 files changed, 261 insertions(+), 10 deletions(-) create mode 100644 assets/controllers.json create mode 100644 tests/TestApplication/.env create mode 100644 tests/TestApplication/config/bundles.php create mode 100644 tests/TestApplication/config/config.yaml create mode 100644 tests/TestApplication/config/routing.yaml create mode 100644 tests/TestApplication/package.json create mode 100644 tests/TestApplication/src/Entity/Customer.php create mode 100644 tests/TestApplication/src/Entity/Payment.php create mode 100644 tests/TestApplication/src/Entity/PaymentMethod.php diff --git a/.gitignore b/.gitignore index 88b66083..19975f9a 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,7 @@ /.idea *.map + +/tests/TestApplication/.env.local +/tests/TestApplication/.env.*.local +/var/ diff --git a/assets/controllers.json b/assets/controllers.json new file mode 100644 index 00000000..5582d953 --- /dev/null +++ b/assets/controllers.json @@ -0,0 +1,41 @@ +{ + "controllers": { + "@payplug/sylius-payplug-plugin": { + "oney-popin": { + "enabled": true, + "fetch": "lazy", + "autoimport": { + "@payplug/sylius-payplug-plugin/shop/dist/oney_common/index.css": true, + "@payplug/sylius-payplug-plugin/shop/dist/oney_popin/index.css": true + } + }, + "integrated-payment": { + "enabled": true, + "fetch": "lazy", + "autoimport": { + "@payplug/sylius-payplug-plugin/shop/dist/payment/integrated.css": true + } + }, + "oney-payment": { + "enabled": true, + "fetch": "lazy" + }, + "payment-logo": { + "enabled": true, + "fetch": "lazy" + }, + "checkout-select-payment": { + "enabled": true, + "fetch": "lazy", + "autoimport": { + "@payplug/sylius-payplug-plugin/shop/dist/payment/index.css": true + } + }, + "apple-pay": { + "enabled": true, + "fetch": "lazy" + } + } + }, + "entrypoints": [] +} diff --git a/composer.json b/composer.json index 7548a5a3..c713005a 100755 --- a/composer.json +++ b/composer.json @@ -10,16 +10,16 @@ "description": "PayPlug payment plugin for Sylius applications.", "license": "MIT", "require": { - "php": "^8.0", + "php": "^8.2", "ext-json": "*", "giggsey/libphonenumber-for-php": "^8.12", "payplug/payplug-php": "^3.1", "php-http/message-factory": "^1.1", "sylius/refund-plugin": "^2.0", "sylius/sylius": "^2.0", - "symfony/asset": "^6.0|^7.0", - "symfony/lock": "^6.0|^7.0", - "symfony/validator": "^6.0|^7.0" + "symfony/asset": "^6.4|| ^7.2", + "symfony/lock": "^6.4|| ^7.2", + "symfony/validator": "^6.4|| ^7.2" }, "require-dev": { "behat/behat": "3.20.0", @@ -49,17 +49,23 @@ "phpunit/phpunit": "9.6.22", "rector/rector": "2.0.4", "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/web-profiler-bundle": "7.2.4", + "sylius/test-application": "^2.1.0@alpha", + "symfony/apache-pack": "*", + "symfony/browser-kit": "^6.4|| ^7.2", + "symfony/debug-bundle": "^6.4|| ^7.2", + "symfony/dotenv": "^6.4|| ^7.2", + "symfony/web-profiler-bundle": "^6.4|| ^7.2", "webmozart/assert": "^1.8" }, "prefer-stable": true, "autoload": { "psr-4": { - "PayPlug\\SyliusPayPlugPlugin\\": "src/", - "Tests\\PayPlug\\SyliusPayPlugPlugin\\": "tests/" + "PayPlug\\SyliusPayPlugPlugin\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "Tests\\PayPlug\\SyliusPayPlugPlugin\\": ["tests/", "tests/TestApplication/src/"] } }, "config": { @@ -70,6 +76,7 @@ "phpro/grumphp": true, "phpstan/extension-installer": true, "symfony/flex": true, + "symfony/runtime": true, "symfony/thanks": true } }, @@ -84,6 +91,26 @@ "@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", + "yarn --cwd vendor/sylius/test-application build", + "vendor/bin/console assets:install --symlink -n" + ], + "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" + } } } diff --git a/tests/TestApplication/.env b/tests/TestApplication/.env new file mode 100644 index 00000000..04c3a5e2 --- /dev/null +++ b/tests/TestApplication/.env @@ -0,0 +1,5 @@ +DATABASE_URL=mysql://root@127.0.0.1/test_application_%kernel.environment% + +SYLIUS_TEST_APP_CONFIGS_TO_IMPORT="@PayPlugSyliusPayPlugPlugin/tests/TestApplication/config/config.yaml" +SYLIUS_TEST_APP_ROUTES_TO_IMPORT="@PayPlugSyliusPayPlugPlugin/tests/TestApplication/config/routing.yaml" +SYLIUS_TEST_APP_BUNDLES_PATH="tests/TestApplication/config/bundles.php" diff --git a/tests/TestApplication/config/bundles.php b/tests/TestApplication/config/bundles.php new file mode 100644 index 00000000..48514e52 --- /dev/null +++ b/tests/TestApplication/config/bundles.php @@ -0,0 +1,8 @@ + ['all' => true], + Knp\Bundle\SnappyBundle\KnpSnappyBundle::class => ['all' => true], + Sylius\RefundPlugin\SyliusRefundPlugin::class => ['all' => true], + PayPlug\SyliusPayPlugPlugin\PayPlugSyliusPayPlugPlugin::class => ['all' => true], +]; diff --git a/tests/TestApplication/config/config.yaml b/tests/TestApplication/config/config.yaml new file mode 100644 index 00000000..1acc0396 --- /dev/null +++ b/tests/TestApplication/config/config.yaml @@ -0,0 +1,87 @@ +imports: + - { resource: "@SyliusRefundPlugin/config/config.yaml" } + - { resource: "@PayPlugSyliusPayPlugPlugin/config/config.yml" } + +parameters: + locale: fr_FR + currency: EUR + sylius_refund.supported_gateways: + - payplug + - payplug_oney + - cash_on_delivery + +sylius_refund: + pdf_generator: + enabled: false + +doctrine: + orm: + entity_managers: + default: + mappings: + TestApplication: + is_bundle: false + type: attribute + dir: '%kernel.project_dir%/../../../tests/TestApplication/src/Entity' + prefix: Tests\PayPlug\SyliusPayPlugPlugin +sylius_customer: + resources: + customer: + classes: + model: Tests\PayPlug\SyliusPayPlugPlugin\Entity\Customer +sylius_payment: + resources: + payment_method: + classes: + model: Tests\PayPlug\SyliusPayPlugPlugin\Entity\PaymentMethod + payment: + classes: + model: Tests\PayPlug\SyliusPayPlugPlugin\Entity\Payment +sylius_fixtures: + suites: + default: + fixtures: + geographical: + options: + countries: + - 'US' + - 'FR' + - 'DE' + - 'AU' + - 'CA' + - 'MX' + - 'NZ' + - 'PT' + - 'ES' + - 'CN' + - 'GB' + - 'PL' + zones: + FR: + name: 'France' + countries: + - 'FR' + + channel: + options: + custom: + fashion_web_store: + name: 'Fashion Web Store' + code: 'FASHION_WEB' + locales: + - '%locale%' + currencies: + - 'EUR' + enabled: true + hostname: '%env(resolve:SYLIUS_FIXTURES_HOSTNAME)%' + theme_name: '%env(resolve:SYLIUS_FIXTURES_THEME_NAME)%' + shop_billing_data: + company: 'Sylius' + tax_id: '0001112222' + country_code: 'FR' + street: 'Test St. 15' + city: 'eCommerce Town' + postcode: '00 33 22' + menu_taxon: 'MENU_CATEGORY' + contact_phone_number: '+41 123 456 789' + contact_email: 'contact@example.com' diff --git a/tests/TestApplication/config/routing.yaml b/tests/TestApplication/config/routing.yaml new file mode 100644 index 00000000..54af5a42 --- /dev/null +++ b/tests/TestApplication/config/routing.yaml @@ -0,0 +1,5 @@ +sylius_refund: + resource: "@SyliusRefundPlugin/config/routes.yaml" + +sylius_payplug: + resource: "@PayPlugSyliusPayPlugPlugin/config/routing.yaml" diff --git a/tests/TestApplication/package.json b/tests/TestApplication/package.json new file mode 100644 index 00000000..0280f00d --- /dev/null +++ b/tests/TestApplication/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "@payplug/sylius-payplug-plugin": "file:../../../assets" + } +} diff --git a/tests/TestApplication/src/Entity/Customer.php b/tests/TestApplication/src/Entity/Customer.php new file mode 100644 index 00000000..05196860 --- /dev/null +++ b/tests/TestApplication/src/Entity/Customer.php @@ -0,0 +1,16 @@ +refundHistories = new ArrayCollection(); + } +} diff --git a/tests/TestApplication/src/Entity/PaymentMethod.php b/tests/TestApplication/src/Entity/PaymentMethod.php new file mode 100644 index 00000000..7dad0a1c --- /dev/null +++ b/tests/TestApplication/src/Entity/PaymentMethod.php @@ -0,0 +1,30 @@ +cards = new ArrayCollection(); + } + + protected function createTranslation(): PaymentMethodTranslationInterface + { + return new PaymentMethodTranslation(); + } +} From c707d0ce3144d9bcfa35be5638ed05a158c26a5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jib=C3=A9=20Barth?= Date: Mon, 21 Jul 2025 15:50:53 +0200 Subject: [PATCH 2/8] [CI] Update makefile and gha for use testApplication --- .github/workflows/sylius.yaml | 18 +++------ Makefile | 75 +++++++---------------------------- 2 files changed, 20 insertions(+), 73 deletions(-) diff --git a/.github/workflows/sylius.yaml b/.github/workflows/sylius.yaml index 9c388a86..90e4bc8c 100644 --- a/.github/workflows/sylius.yaml +++ b/.github/workflows/sylius.yaml @@ -19,10 +19,13 @@ jobs: matrix: php: - 8.2 + - 8.4 sylius: - 2.1.0 + - 2.0.0 symfony: - 6.4 + - 7.3 node: - 18.x env: @@ -43,9 +46,6 @@ jobs: uses: actions/setup-node@v3 with: node-version: '${{ matrix.node }}' - - - name: 'Wkhtmltopdf - Install' - run: "sudo apt-get update\nsudo apt-get install xvfb libfontconfig wkhtmltopdf\nprintf '#!/bin/bash\\nxvfb-run -a --server-args=\"-screen 0, 1024x768x24\" /usr/bin/wkhtmltopdf -q $*' | sudo tee /usr/bin/wkhtmltopdf.sh\nsudo chmod a+x /usr/bin/wkhtmltopdf.sh\nsudo ln -s /usr/bin/wkhtmltopdf.sh /usr/local/bin/wkhtmltopdf\n" - uses: actions/checkout@v3 - @@ -80,27 +80,19 @@ 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' + run: 'make install -e SYLIUS_VERSION=${{ matrix.sylius }} SYMFONY_VERSION=${{ matrix.symfony }}' - 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 --daemon' id: end-of-setup-sylius - name: 'Doctrine Schema Validate - Run' - working-directory: ./tests/Application run: 'php bin/console doctrine:schema:validate --skip-sync' - name: 'Run PHPUnit' diff --git a/Makefile b/Makefile index cc5d2e48..4da061a7 100644 --- a/Makefile +++ b/Makefile @@ -1,28 +1,22 @@ .DEFAULT_GOAL := help SHELL=/bin/bash COMPOSER_ROOT=composer -TEST_DIRECTORY=tests/Application -CONSOLE=cd tests/Application && php bin/console -e test -COMPOSER=cd tests/Application && composer -YARN=cd tests/Application && yarn - -SYLIUS_VERSION=1.12.0 -SYMFONY_VERSION=6.1 -PHP_VERSION=8.1 +TEST_DIRECTORY=tests/TestApplication +CONSOLE=vendor/bin/console +COMPOSER=composer +SYLIUS_VERSION=2.1.0 +SYMFONY_VERSION=6.4 PLUGIN_NAME=payplug/sylius-payplug-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 tests/Application/bin/console)","") ${CONSOLE} doctrine:database:drop --force --if-exists || true -endif - rm -rf tests/Application + rm -rf vendor .PHONY: reset phpunit: phpunit-configure phpunit-run ## Run PHPUnit @@ -31,61 +25,22 @@ phpunit: phpunit-configure phpunit-run ## Run PHPUnit ### ### OTHER ### ¯¯¯¯¯¯ - -sylius: sylius-standard 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 - -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} require "${PLUGIN_NAME}:*" --prefer-source --no-scripts - - cp -r install/Application tests - sed -i "4a \ \ \ \ form_themes: ['form/form_gateway_config_row.html.twig']" ${TEST_DIRECTORY}/config/packages/twig.yaml - mkdir -p ${TEST_DIRECTORY}/templates/form/ - cp -R src/Resources/views/form/* ${TEST_DIRECTORY}/templates/form/ - -# As of sylius/refund-plugin 1.2 the folder does not exist anymore -ifneq ($(PHP_VERSION), 8) - mkdir -p ${TEST_DIRECTORY}/templates/bundles/SyliusAdminBundle/ - cp -R src/Resources/views/SyliusAdminBundle/* ${TEST_DIRECTORY}/templates/bundles/SyliusAdminBundle/ -endif - install-sylius: - #${CONSOLE} sylius:install -n -s default - ${CONSOLE} doctrine:database:create -n - ${CONSOLE} messenger:setup-transports -n - ${CONSOLE} doctrine:migration:migrate -n - ${CONSOLE} sylius:fixture:load -n - ${YARN} install - ${YARN} build - ${YARN} gulp - ${CONSOLE} translation:extract en PayPlugSyliusPayPlugPlugin --dump-messages - ${CONSOLE} translation:extract fr PayPlugSyliusPayPlugPlugin --dump-messages - - ${CONSOLE} cache:clear + @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 # TODO: Remove alpha when stable + ${COMPOSER} test-application:install phpunit-configure: cp phpunit.xml.dist ${TEST_DIRECTORY}/phpunit.xml echo -e "\nMOCK_SERVER_HOST=localhost\nMOCK_SERVER_PORT=8987\n" >> ${TEST_DIRECTORY}/.env.test.local phpunit-run: - cd ${TEST_DIRECTORY} && ./vendor/bin/phpunit + ./vendor/bin/phpunit behat-configure: ## Configure Behat (cd ${TEST_DIRECTORY} && cp behat.yml.dist behat.yml) @@ -101,7 +56,7 @@ grumphp: vendor/bin/grumphp run help: SHELL=/bin/bash -help: ## Dislay this help +help: ## Display this help @IFS=$$'\n'; for line in `grep -h -E '^[a-zA-Z_#-]+:?.*?##.*$$' $(MAKEFILE_LIST)`; do if [ "$${line:0:2}" = "##" ]; then \ echo $$line | awk 'BEGIN {FS = "## "}; {printf "\033[33m %s\033[0m\n", $$2}'; else \ echo $$line | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m%s\n", $$1, $$2}'; fi; \ From 2520fffc2b753875bdd626f3e85a75c681d63239 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jib=C3=A9=20Barth?= Date: Mon, 21 Jul 2025 15:57:55 +0200 Subject: [PATCH 3/8] [CI] Update dev tools --- composer.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/composer.json b/composer.json index c713005a..b98d2ab3 100755 --- a/composer.json +++ b/composer.json @@ -34,8 +34,7 @@ "friends-of-behat/suite-settings-extension": "1.1.0", "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.5.0", "lakion/mink-debug-extension": "2.0.0", "mockery/mockery": "1.6.12", "php-parallel-lint/php-parallel-lint": "1.4.0", From cd7c87e3887d582b7d5cd305da0614723f516d9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jib=C3=A9=20Barth?= Date: Mon, 21 Jul 2025 15:59:16 +0200 Subject: [PATCH 4/8] fixup! [CI] Update makefile and gha for use testApplication --- .github/workflows/sylius.yaml | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/.github/workflows/sylius.yaml b/.github/workflows/sylius.yaml index 90e4bc8c..62413fcf 100644 --- a/.github/workflows/sylius.yaml +++ b/.github/workflows/sylius.yaml @@ -27,7 +27,7 @@ jobs: - 6.4 - 7.3 node: - - 18.x + - 20.x env: APP_ENV: test package-name: payplug/sylius-payplug-plugin @@ -93,20 +93,19 @@ jobs: id: end-of-setup-sylius - name: 'Doctrine Schema Validate - Run' - run: 'php bin/console doctrine:schema:validate --skip-sync' - - - 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''' + run: 'vendor/bin/console doctrine:schema:validate --skip-sync' +# - +# 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() From 15f1652da765b1ad489b53d76afe1e1009e026ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jib=C3=A9=20Barth?= Date: Mon, 21 Jul 2025 16:41:35 +0200 Subject: [PATCH 5/8] [CI] Update PHPunit to use it through testApplication --- .github/workflows/sylius.yaml | 8 ++++---- Makefile | 8 ++------ phpunit.xml.dist | 9 ++++----- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/.github/workflows/sylius.yaml b/.github/workflows/sylius.yaml index 62413fcf..15e307f9 100644 --- a/.github/workflows/sylius.yaml +++ b/.github/workflows/sylius.yaml @@ -94,10 +94,10 @@ jobs: - name: 'Doctrine Schema Validate - Run' run: 'vendor/bin/console doctrine:schema:validate --skip-sync' -# - -# name: 'Run PHPUnit' -# run: 'make phpunit' -# 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' diff --git a/Makefile b/Makefile index 4da061a7..b3007cc4 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,8 @@ reset: ## Remove dependencies rm -rf vendor .PHONY: reset -phpunit: phpunit-configure phpunit-run ## Run PHPUnit +phpunit: ## Run PHPUnit tests + ./vendor/bin/phpunit .PHONY: phpunit ### @@ -35,12 +36,7 @@ install-sylius: ${COMPOSER} require --dev sylius/test-application:"^${SYLIUS_VERSION}@alpha" -n -W # TODO: Remove alpha when stable ${COMPOSER} test-application:install -phpunit-configure: - cp phpunit.xml.dist ${TEST_DIRECTORY}/phpunit.xml - echo -e "\nMOCK_SERVER_HOST=localhost\nMOCK_SERVER_PORT=8987\n" >> ${TEST_DIRECTORY}/.env.test.local -phpunit-run: - ./vendor/bin/phpunit behat-configure: ## Configure Behat (cd ${TEST_DIRECTORY} && cp behat.yml.dist behat.yml) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 8e5a0339..b01264ac 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,19 +1,18 @@ + bootstrap="vendor/sylius/test-application/config/bootstrap.php"> - vendor/payplug/sylius-payplug-plugin/tests/PHPUnit + tests/PHPUnit - - + From a6a41ff9c0f2fc833af56c8d35adf3965c38f7e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jib=C3=A9=20Barth?= Date: Mon, 21 Jul 2025 16:46:39 +0200 Subject: [PATCH 6/8] Clean install folder (no more required) --- install/Application/.gitignore | 3 -- .../Application/config/packages/payplug.yaml | 30 --------------- .../config/packages/sylius_payplug.yaml | 2 - .../config/packages/sylius_refund.yaml | 2 - .../Application/config/routes/payplug.yaml | 2 - .../config/routes/sylius_refund.yaml | 2 - .../Application/config/services_payplug.yaml | 37 ------------------- .../src/Entity/Customer/Customer.php | 27 -------------- .../src/Entity/Payment/Payment.php | 27 -------------- .../src/Entity/Payment/PaymentMethod.php | 33 ----------------- install/app-114/.gitignore | 3 -- install/app-114/config/packages/payplug.yaml | 30 --------------- .../config/packages/sylius_payplug.yaml | 3 -- .../config/packages/sylius_refund.yaml | 2 - install/app-114/config/routes/payplug.yaml | 2 - .../app-114/config/routes/sylius_refund.yaml | 2 - install/app-114/config/services_payplug.yaml | 37 ------------------- .../app-114/src/Entity/Customer/Customer.php | 27 -------------- .../app-114/src/Entity/Payment/Payment.php | 27 -------------- .../src/Entity/Payment/PaymentMethod.php | 33 ----------------- 20 files changed, 331 deletions(-) delete mode 100644 install/Application/.gitignore delete mode 100644 install/Application/config/packages/payplug.yaml delete mode 100644 install/Application/config/packages/sylius_payplug.yaml delete mode 100644 install/Application/config/packages/sylius_refund.yaml delete mode 100644 install/Application/config/routes/payplug.yaml delete mode 100755 install/Application/config/routes/sylius_refund.yaml delete mode 100644 install/Application/config/services_payplug.yaml delete mode 100644 install/Application/src/Entity/Customer/Customer.php delete mode 100644 install/Application/src/Entity/Payment/Payment.php delete mode 100644 install/Application/src/Entity/Payment/PaymentMethod.php delete mode 100644 install/app-114/.gitignore delete mode 100644 install/app-114/config/packages/payplug.yaml delete mode 100644 install/app-114/config/packages/sylius_payplug.yaml delete mode 100644 install/app-114/config/packages/sylius_refund.yaml delete mode 100644 install/app-114/config/routes/payplug.yaml delete mode 100755 install/app-114/config/routes/sylius_refund.yaml delete mode 100644 install/app-114/config/services_payplug.yaml delete mode 100644 install/app-114/src/Entity/Customer/Customer.php delete mode 100644 install/app-114/src/Entity/Payment/Payment.php delete mode 100644 install/app-114/src/Entity/Payment/PaymentMethod.php diff --git a/install/Application/.gitignore b/install/Application/.gitignore deleted file mode 100644 index 83c72082..00000000 --- a/install/Application/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -.env.*.local -.env.local -.env.local.php diff --git a/install/Application/config/packages/payplug.yaml b/install/Application/config/packages/payplug.yaml deleted file mode 100644 index 1d41d8b4..00000000 --- a/install/Application/config/packages/payplug.yaml +++ /dev/null @@ -1,30 +0,0 @@ -parameters: - sylius_refund.supported_gateways: - - payplug - - payplug_oney - - cash_on_delivery - -services: - payplug_sylius_payplug_plugin.api_client.payplug: - class: Tests\PayPlug\SyliusPayPlugPlugin\Behat\Mocker\PayPlugApiClient - public: true - arguments: - - "@service_container" - - 'payplug_sylius_payplug_plugin.api_client.payplug' - - payplug_sylius_payplug_plugin.api_client.oney: - class: Tests\PayPlug\SyliusPayPlugPlugin\Behat\Mocker\PayPlugApiClient - public: true - arguments: - - "@service_container" - - 'payplug_sylius_payplug_plugin.api_client.oney' - - Tests\Sylius\RefundPlugin\Behat\Services\Generator\FailedCreditMemoGenerator: - decorates: 'Sylius\RefundPlugin\Generator\CreditMemoGeneratorInterface' - arguments: - - '@Tests\Sylius\RefundPlugin\Behat\Services\Generator\FailedCreditMemoGenerator.inner' - - Tests\Sylius\RefundPlugin\Behat\Services\Factory\FailedRefundPaymentFactory: - decorates: 'sylius_refund.factory.refund_payment' - arguments: - - '@Tests\Sylius\RefundPlugin\Behat\Services\Factory\FailedRefundPaymentFactory.inner' diff --git a/install/Application/config/packages/sylius_payplug.yaml b/install/Application/config/packages/sylius_payplug.yaml deleted file mode 100644 index 7fe43aa0..00000000 --- a/install/Application/config/packages/sylius_payplug.yaml +++ /dev/null @@ -1,2 +0,0 @@ -imports: - - { resource: "@PayPlugSyliusPayPlugPlugin/config/config.yml" } diff --git a/install/Application/config/packages/sylius_refund.yaml b/install/Application/config/packages/sylius_refund.yaml deleted file mode 100644 index 5107d4fb..00000000 --- a/install/Application/config/packages/sylius_refund.yaml +++ /dev/null @@ -1,2 +0,0 @@ -imports: - - { resource: "@SyliusRefundPlugin/config/config.yaml" } diff --git a/install/Application/config/routes/payplug.yaml b/install/Application/config/routes/payplug.yaml deleted file mode 100644 index d6812b69..00000000 --- a/install/Application/config/routes/payplug.yaml +++ /dev/null @@ -1,2 +0,0 @@ -sylius_payplug: - resource: "@PayPlugSyliusPayPlugPlugin/config/routing.yaml" diff --git a/install/Application/config/routes/sylius_refund.yaml b/install/Application/config/routes/sylius_refund.yaml deleted file mode 100755 index 9e2f267f..00000000 --- a/install/Application/config/routes/sylius_refund.yaml +++ /dev/null @@ -1,2 +0,0 @@ -sylius_refund: - resource: "@SyliusRefundPlugin/config/routes/*.yaml" diff --git a/install/Application/config/services_payplug.yaml b/install/Application/config/services_payplug.yaml deleted file mode 100644 index e7c39ea2..00000000 --- a/install/Application/config/services_payplug.yaml +++ /dev/null @@ -1,37 +0,0 @@ -parameters: - sylius_refund.supported_gateways: - - payplug - - payplug_oney - - cash_on_delivery - -services: - payplug_sylius_payplug_plugin.api_client.payplug: - class: Tests\PayPlug\SyliusPayPlugPlugin\Behat\Mocker\PayPlugApiClient - public: true - arguments: - - "@service_container" - - 'payplug_sylius_payplug_plugin.api_client.payplug' - - payplug_sylius_payplug_plugin.api_client.oney: - class: Tests\PayPlug\SyliusPayPlugPlugin\Behat\Mocker\PayPlugApiClient - public: true - arguments: - - "@service_container" - - 'payplug_sylius_payplug_plugin.api_client.oney' - - PayPlug\SyliusPayPlugPlugin\ApiClient\PayPlugApiClientFactoryInterface: - class: Tests\PayPlug\SyliusPayPlugPlugin\Behat\Mocker\PayPlugApiClientFactory - public: true - arguments: - - "@service_container" - - "payplug_sylius_payplug_plugin.api_client.payplug" - - Tests\Sylius\RefundPlugin\Behat\Services\Generator\FailedCreditMemoGenerator: - decorates: 'Sylius\RefundPlugin\Generator\CreditMemoGeneratorInterface' - arguments: - - '@Tests\Sylius\RefundPlugin\Behat\Services\Generator\FailedCreditMemoGenerator.inner' - - Tests\Sylius\RefundPlugin\Behat\Services\Factory\FailedRefundPaymentFactory: - decorates: 'sylius_refund.factory.refund_payment' - arguments: - - '@Tests\Sylius\RefundPlugin\Behat\Services\Factory\FailedRefundPaymentFactory.inner' diff --git a/install/Application/src/Entity/Customer/Customer.php b/install/Application/src/Entity/Customer/Customer.php deleted file mode 100644 index 6dfffb49..00000000 --- a/install/Application/src/Entity/Customer/Customer.php +++ /dev/null @@ -1,27 +0,0 @@ -cards = new ArrayCollection(); - } -} diff --git a/install/Application/src/Entity/Payment/Payment.php b/install/Application/src/Entity/Payment/Payment.php deleted file mode 100644 index 7a13282a..00000000 --- a/install/Application/src/Entity/Payment/Payment.php +++ /dev/null @@ -1,27 +0,0 @@ -refundHistories = new ArrayCollection(); - } -} diff --git a/install/Application/src/Entity/Payment/PaymentMethod.php b/install/Application/src/Entity/Payment/PaymentMethod.php deleted file mode 100644 index 70cba7d2..00000000 --- a/install/Application/src/Entity/Payment/PaymentMethod.php +++ /dev/null @@ -1,33 +0,0 @@ -cards = new ArrayCollection(); - } - - protected function createTranslation(): PaymentMethodTranslationInterface - { - return new PaymentMethodTranslation(); - } -} diff --git a/install/app-114/.gitignore b/install/app-114/.gitignore deleted file mode 100644 index 83c72082..00000000 --- a/install/app-114/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -.env.*.local -.env.local -.env.local.php diff --git a/install/app-114/config/packages/payplug.yaml b/install/app-114/config/packages/payplug.yaml deleted file mode 100644 index 1d41d8b4..00000000 --- a/install/app-114/config/packages/payplug.yaml +++ /dev/null @@ -1,30 +0,0 @@ -parameters: - sylius_refund.supported_gateways: - - payplug - - payplug_oney - - cash_on_delivery - -services: - payplug_sylius_payplug_plugin.api_client.payplug: - class: Tests\PayPlug\SyliusPayPlugPlugin\Behat\Mocker\PayPlugApiClient - public: true - arguments: - - "@service_container" - - 'payplug_sylius_payplug_plugin.api_client.payplug' - - payplug_sylius_payplug_plugin.api_client.oney: - class: Tests\PayPlug\SyliusPayPlugPlugin\Behat\Mocker\PayPlugApiClient - public: true - arguments: - - "@service_container" - - 'payplug_sylius_payplug_plugin.api_client.oney' - - Tests\Sylius\RefundPlugin\Behat\Services\Generator\FailedCreditMemoGenerator: - decorates: 'Sylius\RefundPlugin\Generator\CreditMemoGeneratorInterface' - arguments: - - '@Tests\Sylius\RefundPlugin\Behat\Services\Generator\FailedCreditMemoGenerator.inner' - - Tests\Sylius\RefundPlugin\Behat\Services\Factory\FailedRefundPaymentFactory: - decorates: 'sylius_refund.factory.refund_payment' - arguments: - - '@Tests\Sylius\RefundPlugin\Behat\Services\Factory\FailedRefundPaymentFactory.inner' diff --git a/install/app-114/config/packages/sylius_payplug.yaml b/install/app-114/config/packages/sylius_payplug.yaml deleted file mode 100644 index 348a3599..00000000 --- a/install/app-114/config/packages/sylius_payplug.yaml +++ /dev/null @@ -1,3 +0,0 @@ -imports: - - { resource: "@PayPlugSyliusPayPlugPlugin/config/config.yml" } - - { resource: "@PayPlugSyliusPayPlugPlugin/config/services.xml" } diff --git a/install/app-114/config/packages/sylius_refund.yaml b/install/app-114/config/packages/sylius_refund.yaml deleted file mode 100644 index ce7ff8ae..00000000 --- a/install/app-114/config/packages/sylius_refund.yaml +++ /dev/null @@ -1,2 +0,0 @@ -imports: - - { resource: "@SyliusRefundPlugin/Resources/config/app/config.yml" } diff --git a/install/app-114/config/routes/payplug.yaml b/install/app-114/config/routes/payplug.yaml deleted file mode 100644 index d6812b69..00000000 --- a/install/app-114/config/routes/payplug.yaml +++ /dev/null @@ -1,2 +0,0 @@ -sylius_payplug: - resource: "@PayPlugSyliusPayPlugPlugin/config/routing.yaml" diff --git a/install/app-114/config/routes/sylius_refund.yaml b/install/app-114/config/routes/sylius_refund.yaml deleted file mode 100755 index 46e99b16..00000000 --- a/install/app-114/config/routes/sylius_refund.yaml +++ /dev/null @@ -1,2 +0,0 @@ -sylius_refund: - resource: "@SyliusRefundPlugin/Resources/config/routing.yml" diff --git a/install/app-114/config/services_payplug.yaml b/install/app-114/config/services_payplug.yaml deleted file mode 100644 index e7c39ea2..00000000 --- a/install/app-114/config/services_payplug.yaml +++ /dev/null @@ -1,37 +0,0 @@ -parameters: - sylius_refund.supported_gateways: - - payplug - - payplug_oney - - cash_on_delivery - -services: - payplug_sylius_payplug_plugin.api_client.payplug: - class: Tests\PayPlug\SyliusPayPlugPlugin\Behat\Mocker\PayPlugApiClient - public: true - arguments: - - "@service_container" - - 'payplug_sylius_payplug_plugin.api_client.payplug' - - payplug_sylius_payplug_plugin.api_client.oney: - class: Tests\PayPlug\SyliusPayPlugPlugin\Behat\Mocker\PayPlugApiClient - public: true - arguments: - - "@service_container" - - 'payplug_sylius_payplug_plugin.api_client.oney' - - PayPlug\SyliusPayPlugPlugin\ApiClient\PayPlugApiClientFactoryInterface: - class: Tests\PayPlug\SyliusPayPlugPlugin\Behat\Mocker\PayPlugApiClientFactory - public: true - arguments: - - "@service_container" - - "payplug_sylius_payplug_plugin.api_client.payplug" - - Tests\Sylius\RefundPlugin\Behat\Services\Generator\FailedCreditMemoGenerator: - decorates: 'Sylius\RefundPlugin\Generator\CreditMemoGeneratorInterface' - arguments: - - '@Tests\Sylius\RefundPlugin\Behat\Services\Generator\FailedCreditMemoGenerator.inner' - - Tests\Sylius\RefundPlugin\Behat\Services\Factory\FailedRefundPaymentFactory: - decorates: 'sylius_refund.factory.refund_payment' - arguments: - - '@Tests\Sylius\RefundPlugin\Behat\Services\Factory\FailedRefundPaymentFactory.inner' diff --git a/install/app-114/src/Entity/Customer/Customer.php b/install/app-114/src/Entity/Customer/Customer.php deleted file mode 100644 index 6dfffb49..00000000 --- a/install/app-114/src/Entity/Customer/Customer.php +++ /dev/null @@ -1,27 +0,0 @@ -cards = new ArrayCollection(); - } -} diff --git a/install/app-114/src/Entity/Payment/Payment.php b/install/app-114/src/Entity/Payment/Payment.php deleted file mode 100644 index 7a13282a..00000000 --- a/install/app-114/src/Entity/Payment/Payment.php +++ /dev/null @@ -1,27 +0,0 @@ -refundHistories = new ArrayCollection(); - } -} diff --git a/install/app-114/src/Entity/Payment/PaymentMethod.php b/install/app-114/src/Entity/Payment/PaymentMethod.php deleted file mode 100644 index 70cba7d2..00000000 --- a/install/app-114/src/Entity/Payment/PaymentMethod.php +++ /dev/null @@ -1,33 +0,0 @@ -cards = new ArrayCollection(); - } - - protected function createTranslation(): PaymentMethodTranslationInterface - { - return new PaymentMethodTranslation(); - } -} From a22938b6a0774b3213563cf20cc1ec921b948105 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jib=C3=A9=20Barth?= Date: Fri, 25 Jul 2025 14:03:37 +0200 Subject: [PATCH 7/8] [Tests] Force sync transport payment request And remove old install directory in phpstan config --- ruleset/phpstan.neon | 4 +--- tests/TestApplication/.env | 2 ++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ruleset/phpstan.neon b/ruleset/phpstan.neon index 3feaeb71..558e1a7d 100644 --- a/ruleset/phpstan.neon +++ b/ruleset/phpstan.neon @@ -12,11 +12,9 @@ parameters: # Makes PHPStan crash - ../src/DependencyInjection/ - ../migrations - # Test dependencies - - ../tests/Application? + - ../tests/TestApplication? - ../tests/PHPUnit - - ../install ignoreErrors: - identifier: missingType.iterableValue - identifier: missingType.generics diff --git a/tests/TestApplication/.env b/tests/TestApplication/.env index 04c3a5e2..8b9cf095 100644 --- a/tests/TestApplication/.env +++ b/tests/TestApplication/.env @@ -3,3 +3,5 @@ DATABASE_URL=mysql://root@127.0.0.1/test_application_%kernel.environment% SYLIUS_TEST_APP_CONFIGS_TO_IMPORT="@PayPlugSyliusPayPlugPlugin/tests/TestApplication/config/config.yaml" SYLIUS_TEST_APP_ROUTES_TO_IMPORT="@PayPlugSyliusPayPlugPlugin/tests/TestApplication/config/routing.yaml" SYLIUS_TEST_APP_BUNDLES_PATH="tests/TestApplication/config/bundles.php" + +SYLIUS_MESSENGER_TRANSPORT_PAYMENT_REQUEST_DSN="sync://" From ec8b57fc00b49b8678c50d502075d1c2e0285115 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jib=C3=A9=20Barth?= Date: Tue, 29 Jul 2025 14:20:58 +0200 Subject: [PATCH 8/8] Add mandatory assets entrypoint Note: They are not required, but mandatory for TestApplication --- assets/admin/entrypoint.js | 2 ++ assets/shop/entrypoint.js | 2 ++ 2 files changed, 4 insertions(+) create mode 100644 assets/admin/entrypoint.js create mode 100644 assets/shop/entrypoint.js diff --git a/assets/admin/entrypoint.js b/assets/admin/entrypoint.js new file mode 100644 index 00000000..25037da5 --- /dev/null +++ b/assets/admin/entrypoint.js @@ -0,0 +1,2 @@ +// Mandatory by test application +// whereas it's useless diff --git a/assets/shop/entrypoint.js b/assets/shop/entrypoint.js new file mode 100644 index 00000000..25037da5 --- /dev/null +++ b/assets/shop/entrypoint.js @@ -0,0 +1,2 @@ +// Mandatory by test application +// whereas it's useless