From 5cabe6910c56b6c53e359fdc4b05677a8e127b0b Mon Sep 17 00:00:00 2001 From: Francis Hilaire Date: Mon, 13 May 2024 16:13:51 +0200 Subject: [PATCH 01/33] Back to normal package.json from Sylius-Standard --- .github/workflows/build.yml | 5 --- tests/Application/.babelrc | 7 ++-- tests/Application/package.json | 13 +++++++ tests/Application/package.json.~1.11.0.dist | 41 --------------------- tests/Application/package.json.~1.12.0.dist | 41 --------------------- 5 files changed, 16 insertions(+), 91 deletions(-) create mode 100755 tests/Application/package.json delete mode 100755 tests/Application/package.json.~1.11.0.dist delete mode 100755 tests/Application/package.json.~1.12.0.dist diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index deeb43d9d..6928c8987 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -126,11 +126,6 @@ jobs: restore-keys: | ${{ runner.os }}-node-${{ matrix.node }}-yarn- - - - name: Copy package.json.dist to package.json - if: matrix.sylius != '' - run: (cd tests/Application && cp package.json.\${{ matrix.sylius }}.dist package.json) - - name: Install JS dependencies run: | diff --git a/tests/Application/.babelrc b/tests/Application/.babelrc index e563a62ea..14eaf4cc4 100644 --- a/tests/Application/.babelrc +++ b/tests/Application/.babelrc @@ -1,14 +1,13 @@ { "presets": [ - ["env", { + ["@babel/preset-env", { "targets": { "node": "6" - }, - "useBuiltIns": true + } }] ], "plugins": [ - ["transform-object-rest-spread", { + ["@babel/plugin-proposal-object-rest-spread", { "useBuiltIns": true }] ] diff --git a/tests/Application/package.json b/tests/Application/package.json new file mode 100755 index 000000000..dfe325839 --- /dev/null +++ b/tests/Application/package.json @@ -0,0 +1,13 @@ +{ + "license": "MIT", + "scripts": { + "build": "encore dev", + "build:prod": "encore production", + "postinstall": "semantic-ui-css-patch", + "lint": "yarn lint:js", + "watch": "encore dev --watch" + }, + "devDependencies": { + "@sylius-ui/frontend": "^1.0" + } +} diff --git a/tests/Application/package.json.~1.11.0.dist b/tests/Application/package.json.~1.11.0.dist deleted file mode 100755 index 9ca356278..000000000 --- a/tests/Application/package.json.~1.11.0.dist +++ /dev/null @@ -1,41 +0,0 @@ -{ - "dependencies": { - "@babel/polyfill": "^7.0.0", - "chart.js": "^2.9.3", - "jquery": "^3.5.0", - "jquery.dirtyforms": "^2.0.0", - "lightbox2": "^2.9.0", - "semantic-ui-css": "^2.2.0", - "slick-carousel": "^1.8.1" - }, - "devDependencies": { - "@symfony/webpack-encore": "^1.6.1", - "babel-core": "^6.26.3", - "babel-plugin-external-helpers": "^6.22.0", - "babel-plugin-module-resolver": "^3.1.1", - "babel-plugin-transform-object-rest-spread": "^6.26.0", - "babel-preset-env": "^1.7.0", - "babel-register": "^6.26.0", - "dedent": "^0.7.0", - "eslint": "^4.19.1", - "eslint-config-airbnb-base": "^12.1.0", - "eslint-import-resolver-babel-module": "^4.0.0", - "eslint-plugin-import": "^2.11.0", - "merge-stream": "^1.0.0", - "sass": "^1.39.2", - "sass-loader": "^12.1.0" - }, - "scripts": { - "dev": "yarn encore dev", - "watch": "yarn encore dev --watch", - "prod": "yarn encore prod", - "lint": "yarn lint:js", - "lint:js": "eslint gulpfile.babel.js" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/Sylius/Sylius.git" - }, - "author": "Paweł Jędrzejewski", - "license": "MIT" -} diff --git a/tests/Application/package.json.~1.12.0.dist b/tests/Application/package.json.~1.12.0.dist deleted file mode 100755 index 36e6c1f0f..000000000 --- a/tests/Application/package.json.~1.12.0.dist +++ /dev/null @@ -1,41 +0,0 @@ -{ - "dependencies": { - "@babel/polyfill": "^7.0.0", - "chart.js": "^3.7.1", - "jquery": "^3.5.0", - "jquery.dirtyforms": "^2.0.0", - "lightbox2": "^2.9.0", - "semantic-ui-css": "^2.2.0", - "slick-carousel": "^1.8.1" - }, - "devDependencies": { - "@symfony/webpack-encore": "^1.6.1", - "babel-core": "^6.26.3", - "babel-plugin-external-helpers": "^6.22.0", - "babel-plugin-module-resolver": "^3.1.1", - "babel-plugin-transform-object-rest-spread": "^6.26.0", - "babel-preset-env": "^1.7.0", - "babel-register": "^6.26.0", - "dedent": "^0.7.0", - "eslint": "^4.19.1", - "eslint-config-airbnb-base": "^12.1.0", - "eslint-import-resolver-babel-module": "^4.0.0", - "eslint-plugin-import": "^2.11.0", - "merge-stream": "^1.0.0", - "sass": "^1.39.2", - "sass-loader": "^12.1.0" - }, - "scripts": { - "dev": "yarn encore dev", - "watch": "yarn encore dev --watch", - "prod": "yarn encore prod", - "lint": "yarn lint:js", - "lint:js": "eslint gulpfile.babel.js" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/Sylius/Sylius.git" - }, - "author": "Paweł Jędrzejewski", - "license": "MIT" -} From 40dc1cffce82f5d00b766f123585e658c9f1c6ef Mon Sep 17 00:00:00 2001 From: Francis Hilaire Date: Mon, 13 May 2024 16:14:28 +0200 Subject: [PATCH 02/33] No migration in the test app so we can remove the config --- tests/Application/config/packages/doctrine_migrations.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/Application/config/packages/doctrine_migrations.yaml b/tests/Application/config/packages/doctrine_migrations.yaml index c2456bfdb..cdbc01ae7 100644 --- a/tests/Application/config/packages/doctrine_migrations.yaml +++ b/tests/Application/config/packages/doctrine_migrations.yaml @@ -2,5 +2,3 @@ doctrine_migrations: storage: table_storage: table_name: sylius_migrations - migrations_paths: - 'DoctrineMigrations': '%kernel.project_dir%/src/Migrations' From 63333ac5ee023a1fbef087676da7e371bf4bc4b7 Mon Sep 17 00:00:00 2001 From: Francis Hilaire Date: Mon, 13 May 2024 16:15:26 +0200 Subject: [PATCH 03/33] new bundles and sync the list from Sylius-Standard --- tests/Application/config/bundles.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/tests/Application/config/bundles.php b/tests/Application/config/bundles.php index 562409827..c23aab419 100644 --- a/tests/Application/config/bundles.php +++ b/tests/Application/config/bundles.php @@ -8,6 +8,8 @@ Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true], Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true], Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true], + Sylius\Abstraction\StateMachine\SyliusStateMachineAbstractionBundle::class => ['all' => true], + Sylius\Calendar\SyliusCalendarBundle::class => ['all' => true], Sylius\Bundle\OrderBundle\SyliusOrderBundle::class => ['all' => true], Sylius\Bundle\MoneyBundle\SyliusMoneyBundle::class => ['all' => true], Sylius\Bundle\CurrencyBundle\SyliusCurrencyBundle::class => ['all' => true], @@ -40,6 +42,7 @@ Liip\ImagineBundle\LiipImagineBundle::class => ['all' => true], Payum\Bundle\PayumBundle\PayumBundle::class => ['all' => true], Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle::class => ['all' => true], + BabDev\PagerfantaBundle\BabDevPagerfantaBundle::class => ['all' => true], Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true], Sylius\Bundle\FixturesBundle\SyliusFixturesBundle::class => ['all' => true], Sylius\Bundle\PayumBundle\SyliusPayumBundle::class => ['all' => true], @@ -48,17 +51,16 @@ Sylius\Bundle\ShopBundle\SyliusShopBundle::class => ['all' => true], Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true, 'test' => true, 'test_cached' => true], Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true, 'test_cached' => true], - FriendsOfBehat\SymfonyExtension\Bundle\FriendsOfBehatSymfonyExtensionBundle::class => ['test' => true, 'test_cached' => true], - Nelmio\Alice\Bridge\Symfony\NelmioAliceBundle::class => ['dev' => true, 'test' => true, 'test_cached' => true], Fidry\AliceDataFixtures\Bridge\Symfony\FidryAliceDataFixturesBundle::class => ['dev' => true, 'test' => true, 'test_cached' => true], - FOS\CKEditorBundle\FOSCKEditorBundle::class => ['all' => true], + Nelmio\Alice\Bridge\Symfony\NelmioAliceBundle::class => ['dev' => true, 'test' => true, 'test_cached' => true], + FriendsOfBehat\SymfonyExtension\Bundle\FriendsOfBehatSymfonyExtensionBundle::class => ['test' => true, 'test_cached' => true], ApiPlatform\Core\Bridge\Symfony\Bundle\ApiPlatformBundle::class => ['all' => true], - Sylius\Bundle\ApiBundle\SyliusApiBundle::class => ['all' => true], Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBundle::class => ['all' => true], + Sylius\Bundle\ApiBundle\SyliusApiBundle::class => ['all' => true], SyliusLabs\DoctrineMigrationsExtraBundle\SyliusLabsDoctrineMigrationsExtraBundle::class => ['all' => true], - BitBag\SyliusCmsPlugin\BitBagSyliusCmsPlugin::class => ['all' => true], - Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true], - Sylius\Bundle\MailerBundle\SyliusMailerBundle::class => ['all' => true], + SyliusLabs\Polyfill\Symfony\Security\Bundle\SyliusLabsPolyfillSymfonySecurityBundle::class => ['all' => true], League\FlysystemBundle\FlysystemBundle::class => ['all' => true], - Sylius\Calendar\SyliusCalendarBundle::class => ['all' => true], + Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true], + FOS\CKEditorBundle\FOSCKEditorBundle::class => ['all' => true], + BitBag\SyliusCmsPlugin\BitBagSyliusCmsPlugin::class => ['all' => true], ]; From 797dcba1739173e45ace3115ad026064f6b32009 Mon Sep 17 00:00:00 2001 From: Francis Hilaire Date: Mon, 13 May 2024 16:15:51 +0200 Subject: [PATCH 04/33] Avoid commiting the yarn.lock --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 6772c7d26..49d8d9d08 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ !/etc/build/.gitignore tests/Application/node_modules/ +tests/Application/yarn.lock tests/Application/var/ !tests/Application/var/.gitkeep From 08f278a8948abc9ef7c56b20f0503c1d18f2c0ea Mon Sep 17 00:00:00 2001 From: Francis Hilaire Date: Mon, 13 May 2024 16:16:52 +0200 Subject: [PATCH 05/33] Remove older sylius versions --- .github/workflows/build.yml | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6928c8987..c065ee945 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,16 +21,12 @@ jobs: strategy: fail-fast: false matrix: - php: ["8.0"] - symfony: ["^5.4", "^6.0"] - sylius: ["~1.11.0", "~1.12.0"] + php: ["8.1"] + symfony: ["^5.4", "^6.4"] + sylius: ["~1.13.0"] node: ["^14.17.x"] mysql: ["8.0"] - exclude: - - sylius: ~1.11.0 - symfony: "^6.0" - env: APP_ENV: test DATABASE_URL: "mysql://root:root@127.0.0.1/sylius?serverVersion=${{ matrix.mysql }}" @@ -136,7 +132,7 @@ jobs: name: Prepare test application database run: | (cd tests/Application && bin/console doctrine:database:create -vvv) - (cd tests/Application && bin/console doctrine:schema:create -vvv) + (cd tests/Application && bin/console doctrine:migrations:migrate -n -vvv -q) - name: Prepare test application assets @@ -191,4 +187,4 @@ jobs: SLACK_MESSAGE: ':x:' SLACK_TITLE: Failed build on ${{ github.event.repository.name }} repository SLACK_USERNAME: ${{ secrets.FAILED_BUILD_SLACK_USERNAME }} - SLACK_WEBHOOK: ${{ secrets.FAILED_BUILD_SLACK_WEBHOOK }} \ No newline at end of file + SLACK_WEBHOOK: ${{ secrets.FAILED_BUILD_SLACK_WEBHOOK }} From e6c226273b66353d9beb2148fd6c6dde910c9388 Mon Sep 17 00:00:00 2001 From: Francis Hilaire Date: Mon, 13 May 2024 16:16:56 +0200 Subject: [PATCH 06/33] Update deps --- composer.json | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/composer.json b/composer.json index fa6f4021c..10fad26d8 100755 --- a/composer.json +++ b/composer.json @@ -9,10 +9,9 @@ "description": "CMS plugin for Sylius applications.", "license": "MIT", "require": { - "php": "^8.0", - "sylius/sylius": "~1.11.0 || ~1.12.0", + "sylius/sylius": "~1.13.0", "league/csv": "^9.1", - "friendsofsymfony/ckeditor-bundle": "^1.1 || ^2.0", + "friendsofsymfony/ckeditor-bundle": "^2.0", "instaclick/php-webdriver": "^1.4", "symfony/webpack-encore-bundle": "^1.12" }, @@ -39,16 +38,17 @@ "phpstan/phpstan-webmozart-assert": "^1.0", "phpunit/phpunit": "^9.5", "sylius-labs/coding-standard": "^4.0", - "symfony/browser-kit": "^5.4 || ^6.0", - "symfony/debug-bundle": "^5.4 || ^6.0", - "symfony/dotenv": "^5.4 || ^6.0", - "symfony/intl": "^5.4 || ^6.0", - "symfony/web-profiler-bundle": "^5.4 || ^6.0", + "symfony/browser-kit": "^5.4 || ^6.4", + "symfony/debug-bundle": "^5.4 || ^6.4", + "symfony/dotenv": "^5.4 || ^6.4", + "symfony/intl": "^5.4 || ^6.4", + "symfony/web-profiler-bundle": "^5.4 || ^6.4", "league/flysystem-bundle": "2.4.0", - "sylius/mailer-bundle": "^1.8 || ^2.0@beta", - "matthiasnoback/symfony-config-test": "^4.3", + "sylius/mailer-bundle": "^2.0", + "matthiasnoback/symfony-config-test": "^5.1", "polishsymfonycommunity/symfony-mocker-container": "^1.0", - "twig/twig": "^2.10.0" + "twig/twig": "^3.10.1", + "rector/rector": "^1.0" }, "conflict": { "symfony/symfony": "4.1.8", @@ -57,7 +57,7 @@ "symfony/routing": "4.1.8", "symfony/doctrine-bridge": "4.4.16" }, - + "suggest": { "stefandoorn/sitemap-plugin": "^2.0@alpha" }, From e3549a0f3a0ae3b80016419accae86290683c1af Mon Sep 17 00:00:00 2001 From: Francis Hilaire Date: Mon, 13 May 2024 18:09:44 +0200 Subject: [PATCH 07/33] Fix PHPSpec since TwigFunction is now final --- spec/Twig/Parser/ContentParserSpec.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/spec/Twig/Parser/ContentParserSpec.php b/spec/Twig/Parser/ContentParserSpec.php index 797087c76..96e4fcdd9 100644 --- a/spec/Twig/Parser/ContentParserSpec.php +++ b/spec/Twig/Parser/ContentParserSpec.php @@ -30,13 +30,12 @@ public function it_implements_content_parser_interface(): void public function it_parses_string_function( Environment $twigEnvironment, - TwigFunction $renderBlockFunction, RenderBlockRuntimeInterface $renderBlockRuntime ): void { + $twigFunctionName = 'bitbag_cms_render_block'; $twigEnvironment->getFunctions()->willReturn([ - 'bitbag_cms_render_block' => $renderBlockFunction, + $twigFunctionName => new TwigFunction($twigFunctionName, [$renderBlockRuntime->getWrappedObject(), 'renderBlock']) ]); - $renderBlockFunction->getCallable()->willReturn([$renderBlockRuntime, 'renderBlock']); $input = "Let's render! {{ bitbag_cms_render_block('intro', '@BitBagSyliusCmsPlugin/Shop/Block/show.html.twig') }}"; @@ -47,13 +46,13 @@ public function it_parses_string_function( public function it_parses_string_functions( Environment $twigEnvironment, - TwigFunction $renderBlockFunction, RenderBlockRuntimeInterface $renderBlockRuntime ): void { + + $twigFunctionName = 'bitbag_cms_render_block'; $twigEnvironment->getFunctions()->willReturn([ - 'bitbag_cms_render_block' => $renderBlockFunction, + $twigFunctionName => new TwigFunction($twigFunctionName, [$renderBlockRuntime->getWrappedObject(), 'renderBlock']) ]); - $renderBlockFunction->getCallable()->willReturn([$renderBlockRuntime, 'renderBlock']); $input = "Let's render! {{ bitbag_cms_render_block('intro', '@BitBagSyliusCmsPlugin/Shop/Block/show.html.twig') }} Let's render twice! {{ bitbag_cms_render_block('intro1', '@BitBagSyliusCmsPlugin/Shop/Block/show.html.twig') }}"; From 654083e7774c85428bc477cf00384a6a4ec56486 Mon Sep 17 00:00:00 2001 From: Francis Hilaire Date: Mon, 13 May 2024 19:18:45 +0200 Subject: [PATCH 08/33] Move to the right place --- PULL_REQUEST_TEMPLATE.md => .github/PULL_REQUEST_TEMPLATE.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename PULL_REQUEST_TEMPLATE.md => .github/PULL_REQUEST_TEMPLATE.md (100%) diff --git a/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md similarity index 100% rename from PULL_REQUEST_TEMPLATE.md rename to .github/PULL_REQUEST_TEMPLATE.md From 66bae230aac5be3542170235cc9e46962a1275d4 Mon Sep 17 00:00:00 2001 From: Francis Hilaire Date: Mon, 13 May 2024 19:19:22 +0200 Subject: [PATCH 09/33] Remove no more needed override (bdi will found the right binary automatically) --- etc/travis/behat.yml | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/etc/travis/behat.yml b/etc/travis/behat.yml index 96f86c358..805b04644 100755 --- a/etc/travis/behat.yml +++ b/etc/travis/behat.yml @@ -1,20 +1 @@ imports: ["behat.yml.dist"] - -default: - extensions: - Behat\MinkExtension: - javascript_session: chromium - sessions: - chromium: - selenium2: - browser: chrome - capabilities: - browserName: chrome - browser: chrome - version: "" - chrome: - binary: "/usr/bin/chromium-browser" - switches: - - "start-fullscreen" - - "start-maximized" - - "no-sandbox" From 54d0cf88272e7185a4182a47bdffdc3ece00af56 Mon Sep 17 00:00:00 2001 From: Francis Hilaire Date: Mon, 13 May 2024 19:20:20 +0200 Subject: [PATCH 10/33] Update phpunit xsi namespace --- phpunit.xml.dist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 13b99a583..aa1bc1a44 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,7 +1,7 @@ From 6daa87ed55e094fce271c7d780a13b651bce0f68 Mon Sep 17 00:00:00 2001 From: Francis Hilaire Date: Mon, 13 May 2024 19:20:50 +0200 Subject: [PATCH 11/33] Allow override phpstan config --- phpstan.neon => phpstan.neon.dist | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename phpstan.neon => phpstan.neon.dist (100%) diff --git a/phpstan.neon b/phpstan.neon.dist similarity index 100% rename from phpstan.neon rename to phpstan.neon.dist From b5d867c09f60897563761cce2a0c2de7f4b7fe92 Mon Sep 17 00:00:00 2001 From: Francis Hilaire Date: Mon, 13 May 2024 19:21:14 +0200 Subject: [PATCH 12/33] Update behat config to use Panther --- behat.yml.dist | 46 ++++++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/behat.yml.dist b/behat.yml.dist index 6c02a541e..822beee02 100755 --- a/behat.yml.dist +++ b/behat.yml.dist @@ -3,8 +3,15 @@ imports: - tests/Behat/Resources/suites.yml default: + formatters: + pretty: + verbose: true + paths: false + snippets: false + extensions: DMore\ChromeExtension\Behat\ServiceContainer\ChromeExtension: ~ + Robertfausk\Behat\PantherExtension: ~ FriendsOfBehat\MinkDebugExtension: directory: etc/build @@ -15,33 +22,30 @@ default: files_path: "%paths.base%/vendor/sylius/sylius/src/Sylius/Behat/Resources/fixtures/" base_url: "https://127.0.0.1:8080/" default_session: symfony - javascript_session: chrome_headless + javascript_session: panther sessions: symfony: symfony: ~ - chrome_headless: + chromedriver: chrome: api_url: http://127.0.0.1:9222 validate_certificate: false - socket_timeout: 60 - 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: + chrome_headless_second_session: + chrome: + api_url: http://127.0.0.1:9222 + validate_certificate: false + panther: + panther: + manager_options: + connection_timeout_in_ms: 5000 + request_timeout_in_ms: 120000 + chromedriver_arguments: + - --log-path=etc/build/chromedriver.log + - --verbose + capabilities: + acceptSslCerts: true + acceptInsecureCerts: true unexpectedAlertBehaviour: accept - firefox: - selenium2: - browser: firefox show_auto: false FriendsOfBehat\SymfonyExtension: @@ -54,3 +58,5 @@ default: FriendsOfBehat\SuiteSettingsExtension: paths: - "features" + + SyliusLabs\SuiteTagsExtension: ~ From 8546d82b6c6bee75717f04d7c7cda9b07c811cac Mon Sep 17 00:00:00 2001 From: Francis Hilaire Date: Mon, 13 May 2024 19:21:28 +0200 Subject: [PATCH 13/33] Cleanup --- .gitignore | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index 49d8d9d08..6168d01ce 100644 --- a/.gitignore +++ b/.gitignore @@ -4,21 +4,21 @@ /etc/build/* !/etc/build/.gitignore -tests/Application/node_modules/ -tests/Application/yarn.lock - -tests/Application/var/ -!tests/Application/var/.gitkeep - -tests/Application/web/* -!tests/Application/web/favicon.ico -!tests/Application/web/app.php -!tests/Application/web/app_dev.php -!tests/Application/web/app_test.php - -/tests/Application/yarn.lock - /composer.lock -/etc/build/* -!/etc/build/.gitkeep +/.phpunit.result.cache +/phpunit.xml +/phpstan.neon +/phpspec.yml +/behat.yml +/drivers + +###> symfony/framework-bundle ### +/.env.local +/.env.local.php +/.env.*.local +/config/secrets/prod/prod.decrypt.private.php +/public/bundles/ +/var/ +/vendor/ +###< symfony/framework-bundle ### From 4b899fe9a7928fabdc2bcdec94f9ddf6f50c5d3a Mon Sep 17 00:00:00 2001 From: Francis Hilaire Date: Mon, 13 May 2024 19:22:17 +0200 Subject: [PATCH 14/33] Update requirement and cleanup already required by sylius/sylius --- composer.json | 46 +++++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/composer.json b/composer.json index 10fad26d8..ebbb26b40 100755 --- a/composer.json +++ b/composer.json @@ -16,39 +16,38 @@ "symfony/webpack-encore-bundle": "^1.12" }, "require-dev": { - "behat/behat": "^3.7", - "behat/mink-selenium2-driver": "~1.6.0", + "behat/behat": "^3.6.1", + "behat/mink-selenium2-driver": "^1.4", + "dbrekelmans/bdi": "^1.1", "bitbag/coding-standard": "^2.0", "dmore/behat-chrome-extension": "^1.3", "dmore/chrome-mink-driver": "^2.7", "friends-of-behat/mink": "^1.8", "friends-of-behat/mink-browserkit-driver": "^1.4", - "friends-of-behat/mink-debug-extension": "^2.0", + "friends-of-behat/mink-debug-extension": "^2.0.0", "friends-of-behat/mink-extension": "^2.4", "friends-of-behat/page-object-extension": "^0.3", "friends-of-behat/suite-settings-extension": "^1.0", "friends-of-behat/symfony-extension": "^2.1", "friends-of-behat/variadic-extension": "^1.3", "lchrusciel/api-test-case": "^4.1 || ^5.0", - "phpspec/phpspec": "^7.0", + "matthiasnoback/symfony-config-test": "^5.1", + "phpspec/phpspec": "^7.2", "phpstan/extension-installer": "^1.0", - "phpstan/phpstan": "^1.0", - "phpstan/phpstan-doctrine": "^1.0", - "phpstan/phpstan-strict-rules": "^1.0", - "phpstan/phpstan-webmozart-assert": "^1.0", - "phpunit/phpunit": "^9.5", - "sylius-labs/coding-standard": "^4.0", + "phpstan/phpstan": "^1.8.1", + "phpstan/phpstan-doctrine": "^1.3", + "phpstan/phpstan-strict-rules": "^1.3.0", + "phpstan/phpstan-webmozart-assert": "^1.2.0", + "phpunit/phpunit": "^10.5", + "polishsymfonycommunity/symfony-mocker-container": "^1.0", + "robertfausk/behat-panther-extension": "^1.1", + "sylius-labs/coding-standard": "^4.2", + "sylius-labs/suite-tags-extension": "^0.2", "symfony/browser-kit": "^5.4 || ^6.4", "symfony/debug-bundle": "^5.4 || ^6.4", "symfony/dotenv": "^5.4 || ^6.4", "symfony/intl": "^5.4 || ^6.4", - "symfony/web-profiler-bundle": "^5.4 || ^6.4", - "league/flysystem-bundle": "2.4.0", - "sylius/mailer-bundle": "^2.0", - "matthiasnoback/symfony-config-test": "^5.1", - "polishsymfonycommunity/symfony-mocker-container": "^1.0", - "twig/twig": "^3.10.1", - "rector/rector": "^1.0" + "symfony/web-profiler-bundle": "^5.4 || ^6.4" }, "conflict": { "symfony/symfony": "4.1.8", @@ -57,7 +56,6 @@ "symfony/routing": "4.1.8", "symfony/doctrine-bridge": "4.4.16" }, - "suggest": { "stefandoorn/sitemap-plugin": "^2.0@alpha" }, @@ -77,9 +75,15 @@ "config": { "allow-plugins": { "composer/package-versions-deprecated": true, - "symfony/thanks": true, - "dealerdirect/phpcodesniffer-composer-installer": true, - "phpstan/extension-installer": true + "dealerdirect/phpcodesniffer-composer-installer": false, + "phpstan/extension-installer": false, + "symfony/flex": false + } + }, + "scripts": { + "auto-scripts": { + "cache:clear": "symfony-cmd", + "assets:install %PUBLIC_DIR%": "symfony-cmd" } } } From c4a444f9551a489a3b8f1e5fcd45e5f33b0030a8 Mon Sep 17 00:00:00 2001 From: Francis Hilaire Date: Mon, 13 May 2024 19:22:47 +0200 Subject: [PATCH 15/33] Update and cleanup to build Sylius 1.13 tests --- .github/workflows/build.yml | 42 ++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c065ee945..663c4ecf7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,17 +14,17 @@ on: jobs: tests: - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest name: "Sylius ${{ matrix.sylius }}, PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}, MySQL ${{ matrix.mysql }}" strategy: fail-fast: false matrix: - php: ["8.1"] + php: ["8.1", "8.2", "8.3"] symfony: ["^5.4", "^6.4"] sylius: ["~1.13.0"] - node: ["^14.17.x"] + node: ["20.x"] mysql: ["8.0"] env: @@ -33,7 +33,7 @@ jobs: steps: - - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Setup PHP @@ -41,12 +41,12 @@ jobs: with: php-version: "${{ matrix.php }}" extensions: intl - tools: symfony + tools: flex, symfony coverage: none - name: Setup Node - uses: actions/setup-node@v1 + uses: actions/setup-node@v4 with: node-version: "${{ matrix.node }}" @@ -80,25 +80,17 @@ jobs: - name: Get Composer cache directory id: composer-cache - run: echo "::set-output name=dir::$(composer config cache-files-dir)" + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - name: Cache Composer - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json **/composer.lock') }} restore-keys: | ${{ runner.os }}-php-${{ matrix.php }}-composer- - - - name: Restrict Symfony version - if: matrix.symfony != '' - run: | - composer global config --no-plugins allow-plugins.symfony/flex true - composer global require --no-progress --no-scripts --no-plugins "symfony/flex:^1.10" - composer config extra.symfony.require "${{ matrix.symfony }}" - - name: Restrict Sylius version if: matrix.sylius != '' @@ -106,16 +98,22 @@ jobs: - name: Install PHP dependencies - run: composer install --no-interaction --no-scripts + run: composer install --no-interaction + env: + SYMFONY_REQUIRE: ${{ matrix.symfony }} + + - + name: Install Behat driver + run: vendor/bin/bdi browser:google-chrome drivers - name: Get Yarn cache directory id: yarn-cache - run: echo "::set-output name=dir::$(yarn cache dir)" + run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT - name: Cache Yarn - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ${{ steps.yarn-cache.outputs.dir }} key: ${{ runner.os }}-node-${{ matrix.node }}-yarn-${{ hashFiles('**/package.json **/yarn.lock') }} @@ -126,7 +124,6 @@ jobs: name: Install JS dependencies run: | (cd tests/Application && yarn install) - (cd tests/Application && yarn encore dev) - name: Prepare test application database @@ -138,6 +135,7 @@ jobs: name: Prepare test application assets run: | (cd tests/Application && bin/console assets:install public -vvv) + (cd tests/Application && yarn build:prod) - name: Prepare test application cache @@ -165,11 +163,11 @@ jobs: - name: Run Behat - run: vendor/bin/behat --colors --strict -vvv --no-interaction || vendor/bin/behat --colors --strict -vvv --no-interaction --rerun + run: vendor/bin/behat --colors --strict -vvv --no-interaction -f progress || vendor/bin/behat --colors --strict -vvv --no-interaction -f progress --rerun - name: Upload Behat logs - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 if: failure() with: name: Behat logs From 59f5c8e56fb6f3131b442488e60085d6dfc5f8b4 Mon Sep 17 00:00:00 2001 From: Francis Hilaire Date: Mon, 13 May 2024 19:23:20 +0200 Subject: [PATCH 16/33] Cleanup and update to tests Sylius 1.13 --- tests/Application/.gitignore | 7 +- tests/Application/Kernel.php | 62 +------- tests/Application/config/services_test.yaml | 8 + .../config/services_test_cached.yaml | 2 + .../config/sylius/1.11/bundles.php | 9 -- .../sylius/1.11/packages/jms_serializer.yaml | 4 - .../config/sylius/1.11/packages/security.yaml | 148 ------------------ .../sylius/1.11/packages/swiftmailer.yaml | 2 - .../1.11/packages/test/swiftmailer.yaml | 6 - .../packages/test_cached/swiftmailer.yaml | 6 - .../config/sylius/1.11/services_test.yaml | 3 - .../config/sylius/1.12/bundles.php | 8 - .../sylius/1.12/packages/jms_serializer.yaml | 4 - .../config/sylius/1.12/packages/security.yaml | 124 --------------- .../config/sylius/1.12/services_test.yaml | 3 - .../Behat/Resources/services.sylius.1.11.yml | 8 - .../Resources/services/api.sylius.1.11.yml | 35 ----- 17 files changed, 18 insertions(+), 421 deletions(-) create mode 100644 tests/Application/config/services_test.yaml create mode 100644 tests/Application/config/services_test_cached.yaml delete mode 100644 tests/Application/config/sylius/1.11/bundles.php delete mode 100644 tests/Application/config/sylius/1.11/packages/jms_serializer.yaml delete mode 100644 tests/Application/config/sylius/1.11/packages/security.yaml delete mode 100644 tests/Application/config/sylius/1.11/packages/swiftmailer.yaml delete mode 100644 tests/Application/config/sylius/1.11/packages/test/swiftmailer.yaml delete mode 100644 tests/Application/config/sylius/1.11/packages/test_cached/swiftmailer.yaml delete mode 100644 tests/Application/config/sylius/1.11/services_test.yaml delete mode 100644 tests/Application/config/sylius/1.12/bundles.php delete mode 100644 tests/Application/config/sylius/1.12/packages/jms_serializer.yaml delete mode 100644 tests/Application/config/sylius/1.12/packages/security.yaml delete mode 100644 tests/Application/config/sylius/1.12/services_test.yaml delete mode 100755 tests/Behat/Resources/services.sylius.1.11.yml delete mode 100644 tests/Behat/Resources/services/api.sylius.1.11.yml diff --git a/tests/Application/.gitignore b/tests/Application/.gitignore index 871a97acd..ae0b710a0 100644 --- a/tests/Application/.gitignore +++ b/tests/Application/.gitignore @@ -9,16 +9,13 @@ /node_modules /yarn-error.log +/yarn.lock ###> symfony/framework-bundle ### -/.env.*.local /.env.local /.env.local.php +/.env.*.local /public/bundles /var/ /vendor/ ###< symfony/framework-bundle ### - -###> symfony/web-server-bundle ### -/.web-server-pid -###< symfony/web-server-bundle ### diff --git a/tests/Application/Kernel.php b/tests/Application/Kernel.php index 52230c23e..790bd4841 100755 --- a/tests/Application/Kernel.php +++ b/tests/Application/Kernel.php @@ -7,24 +7,9 @@ use PSS\SymfonyMockerContainer\DependencyInjection\MockerContainer; use Sylius\Bundle\CoreBundle\Application\Kernel as SyliusKernel; use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; -use Symfony\Component\Config\Loader\DelegatingLoader; -use Symfony\Component\Config\Loader\LoaderInterface; -use Symfony\Component\Config\Loader\LoaderResolver; -use Symfony\Component\Config\Resource\FileResource; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\DependencyInjection\Loader\ClosureLoader; -use Symfony\Component\DependencyInjection\Loader\DirectoryLoader; -use Symfony\Component\DependencyInjection\Loader\GlobFileLoader; -use Symfony\Component\DependencyInjection\Loader\IniFileLoader; -use Symfony\Component\DependencyInjection\Loader\PhpFileLoader; -use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; -use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; use Symfony\Component\HttpKernel\Bundle\BundleInterface; -use Symfony\Component\HttpKernel\Config\FileLocator; use Symfony\Component\HttpKernel\Kernel as BaseKernel; use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; -use Webmozart\Assert\Assert; final class Kernel extends BaseKernel { @@ -53,23 +38,6 @@ public function registerBundles(): iterable } } - protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void - { - $container->addResource(new FileResource($this->getProjectDir() . '/config/bundles.php')); - $container->setParameter('container.dumper.inline_class_loader', true); - $confDir = $this->getProjectDir() . '/config'; - $syliusDir = $this->getProjectDir() . '/config/sylius/' . SyliusKernel::MAJOR_VERSION . '.' . SyliusKernel::MINOR_VERSION; - - $loader->load($confDir . '/{packages}/*' . self::CONFIG_EXTS, 'glob'); - $loader->load($confDir . '/{packages}/' . $this->environment . '/**/*' . self::CONFIG_EXTS, 'glob'); - $loader->load($confDir . '/{services}' . self::CONFIG_EXTS, 'glob'); - $loader->load($confDir . '/{services}_' . $this->environment . self::CONFIG_EXTS, 'glob'); - if (is_dir($syliusDir)) { - $loader->load($syliusDir . '/{services}_' . $this->environment . self::CONFIG_EXTS, 'glob'); - } - $loader->load($confDir . '/{api_resources}/*' . self::CONFIG_EXTS, 'glob'); - } - protected function configureRoutes(RoutingConfigurator $routes): void { foreach ($this->getConfigurationDirectories() as $confDir) { @@ -77,13 +45,6 @@ protected function configureRoutes(RoutingConfigurator $routes): void } } - private function loadRoutesConfiguration(RoutingConfigurator $routes, string $confDir): void - { - $routes->import($confDir . '/{routes}/*' . self::CONFIG_EXTS); - $routes->import($confDir . '/{routes}/' . $this->environment . '/**/*' . self::CONFIG_EXTS); - $routes->import($confDir . '/{routes}' . self::CONFIG_EXTS); - } - protected function getContainerBaseClass(): string { if ($this->isTestEnvironment() && class_exists(MockerContainer::class)) { @@ -93,27 +54,16 @@ protected function getContainerBaseClass(): string return parent::getContainerBaseClass(); } - protected function getContainerLoader(ContainerInterface $container): DelegatingLoader + private function isTestEnvironment(): bool { - Assert::isInstanceOf($container, ContainerBuilder::class); - - $locator = new FileLocator($this); - $resolver = new LoaderResolver([ - new XmlFileLoader($container, $locator), - new YamlFileLoader($container, $locator), - new IniFileLoader($container, $locator), - new PhpFileLoader($container, $locator), - new GlobFileLoader($container, $locator), - new DirectoryLoader($container, $locator), - new ClosureLoader($container), - ]); - - return new DelegatingLoader($resolver); + return 0 === strpos($this->getEnvironment(), 'test'); } - private function isTestEnvironment(): bool + private function loadRoutesConfiguration(RoutingConfigurator $routes, string $confDir): void { - return 0 === strpos($this->getEnvironment(), 'test'); + $routes->import($confDir . '/{routes}/*' . self::CONFIG_EXTS); + $routes->import($confDir . '/{routes}/' . $this->environment . '/**/*' . self::CONFIG_EXTS); + $routes->import($confDir . '/{routes}' . self::CONFIG_EXTS); } /** diff --git a/tests/Application/config/services_test.yaml b/tests/Application/config/services_test.yaml new file mode 100644 index 000000000..f90fe4203 --- /dev/null +++ b/tests/Application/config/services_test.yaml @@ -0,0 +1,8 @@ +imports: + - { resource: "../../Behat/Resources/services.yml" } + - { resource: "../../../vendor/sylius/sylius/src/Sylius/Behat/Resources/config/services.xml" } + +# workaround needed for strange "test.client.history" problem +# see https://github.com/FriendsOfBehat/SymfonyExtension/issues/88 +services: + Symfony\Component\BrowserKit\AbstractBrowser: '@test.client' diff --git a/tests/Application/config/services_test_cached.yaml b/tests/Application/config/services_test_cached.yaml new file mode 100644 index 000000000..5d2c7fa48 --- /dev/null +++ b/tests/Application/config/services_test_cached.yaml @@ -0,0 +1,2 @@ +imports: + - { resource: "services_test.yaml" } diff --git a/tests/Application/config/sylius/1.11/bundles.php b/tests/Application/config/sylius/1.11/bundles.php deleted file mode 100644 index fc6ec3af0..000000000 --- a/tests/Application/config/sylius/1.11/bundles.php +++ /dev/null @@ -1,9 +0,0 @@ - ['all' => true], - SyliusLabs\Polyfill\Symfony\Security\Bundle\SyliusLabsPolyfillSymfonySecurityBundle::class => ['all' => true], - Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle::class => ['all' => true], -]; diff --git a/tests/Application/config/sylius/1.11/packages/jms_serializer.yaml b/tests/Application/config/sylius/1.11/packages/jms_serializer.yaml deleted file mode 100644 index ed7bc613f..000000000 --- a/tests/Application/config/sylius/1.11/packages/jms_serializer.yaml +++ /dev/null @@ -1,4 +0,0 @@ -jms_serializer: - visitors: - xml_serialization: - format_output: '%kernel.debug%' diff --git a/tests/Application/config/sylius/1.11/packages/security.yaml b/tests/Application/config/sylius/1.11/packages/security.yaml deleted file mode 100644 index 10628102a..000000000 --- a/tests/Application/config/sylius/1.11/packages/security.yaml +++ /dev/null @@ -1,148 +0,0 @@ -parameters: - sylius.security.admin_regex: "^/%sylius_admin.path_name%" - sylius.security.api_regex: "^/api" - sylius.security.shop_regex: "^/(?!%sylius_admin.path_name%|new-api|api/.*|api$|media/.*)[^/]++" - sylius.security.new_api_route: "/new-api" - sylius.security.new_api_regex: "^%sylius.security.new_api_route%" - sylius.security.new_api_admin_route: "%sylius.security.new_api_route%/admin" - sylius.security.new_api_admin_regex: "^%sylius.security.new_api_admin_route%" - sylius.security.new_api_shop_route: "%sylius.security.new_api_route%/shop" - sylius.security.new_api_shop_regex: "^%sylius.security.new_api_shop_route%" - -security: - always_authenticate_before_granting: true - providers: - sylius_admin_user_provider: - id: sylius.admin_user_provider.email_or_name_based - sylius_api_admin_user_provider: - id: sylius.admin_user_provider.email_or_name_based - sylius_shop_user_provider: - id: sylius.shop_user_provider.email_or_name_based - sylius_api_shop_user_provider: - id: sylius.shop_user_provider.email_or_name_based - sylius_api_chain_provider: - chain: - providers: [sylius_api_shop_user_provider, sylius_api_admin_user_provider] - - encoders: - Sylius\Component\User\Model\UserInterface: argon2i - firewalls: - admin: - switch_user: true - context: admin - pattern: "%sylius.security.admin_regex%" - provider: sylius_admin_user_provider - form_login: - provider: sylius_admin_user_provider - login_path: sylius_admin_login - check_path: sylius_admin_login_check - failure_path: sylius_admin_login - default_target_path: sylius_admin_dashboard - use_forward: false - use_referer: true - csrf_token_generator: security.csrf.token_manager - csrf_parameter: _csrf_admin_security_token - csrf_token_id: admin_authenticate - remember_me: - secret: "%env(APP_SECRET)%" - path: "/%sylius_admin.path_name%" - name: APP_ADMIN_REMEMBER_ME - lifetime: 31536000 - remember_me_parameter: _remember_me - logout: - path: sylius_admin_logout - target: sylius_admin_login - anonymous: true - - new_api_admin_user: - pattern: "%sylius.security.new_api_route%/admin-user-authentication-token" - provider: sylius_admin_user_provider - stateless: true - anonymous: true - json_login: - check_path: "%sylius.security.new_api_route%/admin-user-authentication-token" - username_path: email - password_path: password - success_handler: lexik_jwt_authentication.handler.authentication_success - failure_handler: lexik_jwt_authentication.handler.authentication_failure - guard: - authenticators: - - lexik_jwt_authentication.jwt_token_authenticator - - new_api_shop_user: - pattern: "%sylius.security.new_api_route%/shop-user-authentication-token" - provider: sylius_shop_user_provider - stateless: true - anonymous: true - json_login: - check_path: "%sylius.security.new_api_route%/shop-user-authentication-token" - username_path: email - password_path: password - success_handler: lexik_jwt_authentication.handler.authentication_success - failure_handler: lexik_jwt_authentication.handler.authentication_failure - guard: - authenticators: - - lexik_jwt_authentication.jwt_token_authenticator - - new_api: - pattern: "%sylius.security.new_api_regex%/*" - provider: sylius_api_chain_provider - stateless: true - anonymous: lazy - guard: - authenticators: - - lexik_jwt_authentication.jwt_token_authenticator - - shop: - switch_user: { role: ROLE_ALLOWED_TO_SWITCH } - context: shop - pattern: "%sylius.security.shop_regex%" - provider: sylius_shop_user_provider - form_login: - success_handler: sylius.authentication.success_handler - failure_handler: sylius.authentication.failure_handler - provider: sylius_shop_user_provider - login_path: sylius_shop_login - check_path: sylius_shop_login_check - failure_path: sylius_shop_login - default_target_path: sylius_shop_homepage - use_forward: false - use_referer: true - csrf_token_generator: security.csrf.token_manager - csrf_parameter: _csrf_shop_security_token - csrf_token_id: shop_authenticate - remember_me: - secret: "%env(APP_SECRET)%" - name: APP_SHOP_REMEMBER_ME - lifetime: 31536000 - remember_me_parameter: _remember_me - logout: - path: sylius_shop_logout - target: sylius_shop_login - invalidate_session: false - success_handler: sylius.handler.shop_user_logout - anonymous: true - - dev: - pattern: ^/(_(profiler|wdt)|css|images|js)/ - security: false - - access_control: - - { path: "%sylius.security.admin_regex%/_partial", role: IS_AUTHENTICATED_ANONYMOUSLY, ips: [127.0.0.1, ::1] } - - { path: "%sylius.security.admin_regex%/_partial", role: ROLE_NO_ACCESS } - - { path: "%sylius.security.shop_regex%/_partial", role: IS_AUTHENTICATED_ANONYMOUSLY, ips: [127.0.0.1, ::1] } - - { path: "%sylius.security.shop_regex%/_partial", role: ROLE_NO_ACCESS } - - - { path: "%sylius.security.admin_regex%/login", role: IS_AUTHENTICATED_ANONYMOUSLY } - - { path: "%sylius.security.api_regex%/login", role: IS_AUTHENTICATED_ANONYMOUSLY } - - { path: "%sylius.security.shop_regex%/login", role: IS_AUTHENTICATED_ANONYMOUSLY } - - - { path: "%sylius.security.shop_regex%/register", role: IS_AUTHENTICATED_ANONYMOUSLY } - - { path: "%sylius.security.shop_regex%/verify", role: IS_AUTHENTICATED_ANONYMOUSLY } - - - { path: "%sylius.security.admin_regex%", role: ROLE_ADMINISTRATION_ACCESS } - - { path: "%sylius.security.api_regex%/.*", role: ROLE_API_ACCESS } - - { path: "%sylius.security.shop_regex%/account", role: ROLE_USER } - - - { path: "%sylius.security.new_api_admin_regex%/.*", role: ROLE_API_ACCESS } - - { path: "%sylius.security.new_api_shop_regex%/.*", role: IS_AUTHENTICATED_ANONYMOUSLY } diff --git a/tests/Application/config/sylius/1.11/packages/swiftmailer.yaml b/tests/Application/config/sylius/1.11/packages/swiftmailer.yaml deleted file mode 100644 index 73bba2755..000000000 --- a/tests/Application/config/sylius/1.11/packages/swiftmailer.yaml +++ /dev/null @@ -1,2 +0,0 @@ -swiftmailer: - url: '%env(MAILER_URL)%' diff --git a/tests/Application/config/sylius/1.11/packages/test/swiftmailer.yaml b/tests/Application/config/sylius/1.11/packages/test/swiftmailer.yaml deleted file mode 100644 index cf16fdfed..000000000 --- a/tests/Application/config/sylius/1.11/packages/test/swiftmailer.yaml +++ /dev/null @@ -1,6 +0,0 @@ -swiftmailer: - disable_delivery: true - logging: true - spool: - type: file - path: "%kernel.cache_dir%/spool" \ No newline at end of file diff --git a/tests/Application/config/sylius/1.11/packages/test_cached/swiftmailer.yaml b/tests/Application/config/sylius/1.11/packages/test_cached/swiftmailer.yaml deleted file mode 100644 index cf16fdfed..000000000 --- a/tests/Application/config/sylius/1.11/packages/test_cached/swiftmailer.yaml +++ /dev/null @@ -1,6 +0,0 @@ -swiftmailer: - disable_delivery: true - logging: true - spool: - type: file - path: "%kernel.cache_dir%/spool" \ No newline at end of file diff --git a/tests/Application/config/sylius/1.11/services_test.yaml b/tests/Application/config/sylius/1.11/services_test.yaml deleted file mode 100644 index bf7b55e79..000000000 --- a/tests/Application/config/sylius/1.11/services_test.yaml +++ /dev/null @@ -1,3 +0,0 @@ -imports: - - { resource: "../../../../Behat/Resources/services.sylius.1.11.yml" } - - { resource: "../../../../../vendor/sylius/sylius/src/Sylius/Behat/Resources/config/services.xml" } diff --git a/tests/Application/config/sylius/1.12/bundles.php b/tests/Application/config/sylius/1.12/bundles.php deleted file mode 100644 index d50639f7b..000000000 --- a/tests/Application/config/sylius/1.12/bundles.php +++ /dev/null @@ -1,8 +0,0 @@ - ['all' => true], - SyliusLabs\Polyfill\Symfony\Security\Bundle\SyliusLabsPolyfillSymfonySecurityBundle::class => ['all' => true], -]; diff --git a/tests/Application/config/sylius/1.12/packages/jms_serializer.yaml b/tests/Application/config/sylius/1.12/packages/jms_serializer.yaml deleted file mode 100644 index ed7bc613f..000000000 --- a/tests/Application/config/sylius/1.12/packages/jms_serializer.yaml +++ /dev/null @@ -1,4 +0,0 @@ -jms_serializer: - visitors: - xml_serialization: - format_output: '%kernel.debug%' diff --git a/tests/Application/config/sylius/1.12/packages/security.yaml b/tests/Application/config/sylius/1.12/packages/security.yaml deleted file mode 100644 index 4ed342f82..000000000 --- a/tests/Application/config/sylius/1.12/packages/security.yaml +++ /dev/null @@ -1,124 +0,0 @@ -security: - enable_authenticator_manager: true - providers: - sylius_admin_user_provider: - id: sylius.admin_user_provider.email_or_name_based - sylius_api_admin_user_provider: - id: sylius.admin_user_provider.email_or_name_based - sylius_shop_user_provider: - id: sylius.shop_user_provider.email_or_name_based - sylius_api_shop_user_provider: - id: sylius.shop_user_provider.email_or_name_based - - password_hashers: - Sylius\Component\User\Model\UserInterface: argon2i - firewalls: - admin: - switch_user: true - context: admin - pattern: "%sylius.security.admin_regex%" - provider: sylius_admin_user_provider - form_login: - provider: sylius_admin_user_provider - login_path: sylius_admin_login - check_path: sylius_admin_login_check - failure_path: sylius_admin_login - default_target_path: sylius_admin_dashboard - use_forward: false - use_referer: true - enable_csrf: true - csrf_parameter: _csrf_admin_security_token - csrf_token_id: admin_authenticate - remember_me: - secret: "%env(APP_SECRET)%" - path: "/%sylius_admin.path_name%" - name: APP_ADMIN_REMEMBER_ME - lifetime: 31536000 - remember_me_parameter: _remember_me - logout: - path: sylius_admin_logout - target: sylius_admin_login - - new_api_admin_user: - pattern: "%sylius.security.new_api_admin_regex%/.*" - provider: sylius_api_admin_user_provider - stateless: true - entry_point: jwt - json_login: - check_path: "%sylius.security.new_api_admin_route%/authentication-token" - username_path: email - password_path: password - success_handler: lexik_jwt_authentication.handler.authentication_success - failure_handler: lexik_jwt_authentication.handler.authentication_failure - jwt: true - - new_api_shop_user: - pattern: "%sylius.security.new_api_shop_regex%/.*" - provider: sylius_api_shop_user_provider - stateless: true - entry_point: jwt - json_login: - check_path: "%sylius.security.new_api_shop_route%/authentication-token" - username_path: email - password_path: password - success_handler: lexik_jwt_authentication.handler.authentication_success - failure_handler: lexik_jwt_authentication.handler.authentication_failure - jwt: true - - shop: - switch_user: { role: ROLE_ALLOWED_TO_SWITCH } - context: shop - pattern: "%sylius.security.shop_regex%" - provider: sylius_shop_user_provider - form_login: - success_handler: sylius.authentication.success_handler - failure_handler: sylius.authentication.failure_handler - provider: sylius_shop_user_provider - login_path: sylius_shop_login - check_path: sylius_shop_login_check - failure_path: sylius_shop_login - default_target_path: sylius_shop_homepage - use_forward: false - use_referer: true - enable_csrf: true - csrf_parameter: _csrf_shop_security_token - csrf_token_id: shop_authenticate - remember_me: - secret: "%env(APP_SECRET)%" - name: APP_SHOP_REMEMBER_ME - lifetime: 31536000 - remember_me_parameter: _remember_me - logout: - path: sylius_shop_logout - target: sylius_shop_homepage - invalidate_session: false - - dev: - pattern: ^/(_(profiler|wdt)|css|images|js)/ - security: false - - image_resolver: - pattern: ^/media/cache/resolve - security: false - - access_control: - - { path: "%sylius.security.admin_regex%/_partial", role: PUBLIC_ACCESS, ips: [127.0.0.1, ::1] } - - { path: "%sylius.security.admin_regex%/_partial", role: ROLE_NO_ACCESS } - - { path: "%sylius.security.shop_regex%/_partial", role: PUBLIC_ACCESS, ips: [127.0.0.1, ::1] } - - { path: "%sylius.security.shop_regex%/_partial", role: ROLE_NO_ACCESS } - - - { path: "%sylius.security.admin_regex%/login", role: PUBLIC_ACCESS } - - { path: "%sylius.security.shop_regex%/login", role: PUBLIC_ACCESS } - - - { path: "%sylius.security.shop_regex%/register", role: PUBLIC_ACCESS } - - { path: "%sylius.security.shop_regex%/verify", role: PUBLIC_ACCESS } - - - { path: "%sylius.security.admin_regex%", role: ROLE_ADMINISTRATION_ACCESS } - - { path: "%sylius.security.shop_regex%/account", role: ROLE_USER } - - - { path: "%sylius.security.new_api_admin_route%/reset-password-requests", role: PUBLIC_ACCESS } - - { path: "%sylius.security.new_api_admin_regex%/.*", role: ROLE_API_ACCESS } - - { path: "%sylius.security.new_api_admin_route%/authentication-token", role: PUBLIC_ACCESS } - - { path: "%sylius.security.new_api_user_account_regex%/.*", role: ROLE_USER } - - { path: "%sylius.security.new_api_shop_route%/authentication-token", role: PUBLIC_ACCESS } - - { path: "%sylius.security.new_api_shop_regex%/.*", role: PUBLIC_ACCESS } diff --git a/tests/Application/config/sylius/1.12/services_test.yaml b/tests/Application/config/sylius/1.12/services_test.yaml deleted file mode 100644 index 11f60224d..000000000 --- a/tests/Application/config/sylius/1.12/services_test.yaml +++ /dev/null @@ -1,3 +0,0 @@ -imports: - - { resource: "../../../../Behat/Resources/services.yml" } - - { resource: "../../../../../vendor/sylius/sylius/src/Sylius/Behat/Resources/config/services.xml" } diff --git a/tests/Behat/Resources/services.sylius.1.11.yml b/tests/Behat/Resources/services.sylius.1.11.yml deleted file mode 100755 index 9070756ec..000000000 --- a/tests/Behat/Resources/services.sylius.1.11.yml +++ /dev/null @@ -1,8 +0,0 @@ -imports: - - { resource: "services/contexts.yml" } - - { resource: "services/pages.yml" } - - { resource: "services/api.sylius.1.11.yml" } - -services: - bitbag_sylius_cms_plugin.behat.random_string_generator: - class: Tests\BitBag\SyliusCmsPlugin\Behat\Service\RandomStringGenerator diff --git a/tests/Behat/Resources/services/api.sylius.1.11.yml b/tests/Behat/Resources/services/api.sylius.1.11.yml deleted file mode 100644 index d4440cef0..000000000 --- a/tests/Behat/Resources/services/api.sylius.1.11.yml +++ /dev/null @@ -1,35 +0,0 @@ -services: - bitbag_sylius_cms_plugin.behat.api_platform_client.shop.block: - class: Sylius\Behat\Client\ApiPlatformClient - parent: sylius.behat.api_platform_client - arguments: - - 'blocks' - - 'shop/cms-plugin' - - bitbag_sylius_cms_plugin.behat.api_platform_client.shop.frequently_asked_question: - class: Sylius\Behat\Client\ApiPlatformClient - parent: sylius.behat.api_platform_client - arguments: - - 'faq' - - 'shop/cms-plugin' - - bitbag_sylius_cms_plugin.behat.api_platform_client.shop.media: - class: Sylius\Behat\Client\ApiPlatformClient - parent: sylius.behat.api_platform_client - arguments: - - 'media' - - 'shop/cms-plugin' - - bitbag_sylius_cms_plugin.behat.api_platform_client.shop.page: - class: Sylius\Behat\Client\ApiPlatformClient - parent: sylius.behat.api_platform_client - arguments: - - 'pages' - - 'shop/cms-plugin' - - bitbag_sylius_cms_plugin.behat.api_platform_client.shop.section: - class: Sylius\Behat\Client\ApiPlatformClient - parent: sylius.behat.api_platform_client - arguments: - - 'sections' - - 'shop/cms-plugin' From d7189b7c407320dd3613ce213bba20cf22394fb9 Mon Sep 17 00:00:00 2001 From: Francis Hilaire Date: Mon, 13 May 2024 20:51:15 +0200 Subject: [PATCH 17/33] Use Symfony runtime --- composer.json | 12 +++++----- tests/Application/.env | 5 ++++- tests/Application/bin/console | 35 +++++------------------------- tests/Application/public/index.php | 26 ++++------------------ 4 files changed, 21 insertions(+), 57 deletions(-) diff --git a/composer.json b/composer.json index ebbb26b40..5a22567d9 100755 --- a/composer.json +++ b/composer.json @@ -47,6 +47,7 @@ "symfony/debug-bundle": "^5.4 || ^6.4", "symfony/dotenv": "^5.4 || ^6.4", "symfony/intl": "^5.4 || ^6.4", + "symfony/runtime": "^5.4 || ^6.4", "symfony/web-profiler-bundle": "^5.4 || ^6.4" }, "conflict": { @@ -77,13 +78,14 @@ "composer/package-versions-deprecated": true, "dealerdirect/phpcodesniffer-composer-installer": false, "phpstan/extension-installer": false, - "symfony/flex": false + "symfony/flex": false, + "symfony/runtime": true } }, - "scripts": { - "auto-scripts": { - "cache:clear": "symfony-cmd", - "assets:install %PUBLIC_DIR%": "symfony-cmd" + "extra": { + "runtime": { + "project_dir": "tests/Application", + "dotenv_path": "tests/Application/.env" } } } diff --git a/tests/Application/.env b/tests/Application/.env index 3f3595b34..9aa4fccd3 100644 --- a/tests/Application/.env +++ b/tests/Application/.env @@ -33,5 +33,8 @@ JWT_PASSPHRASE=YOUR_SECRET_PASSPHRASE # MESSENGER_TRANSPORT_DSN=amqp://guest:guest@localhost:5672/%2f/messages # MESSENGER_TRANSPORT_DSN=doctrine://default # MESSENGER_TRANSPORT_DSN=redis://localhost:6379/messages -MESSENGER_TRANSPORT_DSN=sync:// +SYLIUS_MESSENGER_TRANSPORT_MAIN_DSN=sync:// +SYLIUS_MESSENGER_TRANSPORT_MAIN_FAILED_DSN=sync:// +SYLIUS_MESSENGER_TRANSPORT_CATALOG_PROMOTION_REMOVAL_DSN=sync:// +SYLIUS_MESSENGER_TRANSPORT_CATALOG_PROMOTION_REMOVAL_FAILED_DSN=sync:// ###< symfony/messenger ### diff --git a/tests/Application/bin/console b/tests/Application/bin/console index cee26f0b7..8ff019cdd 100755 --- a/tests/Application/bin/console +++ b/tests/Application/bin/console @@ -3,36 +3,13 @@ use Tests\BitBag\SyliusCmsPlugin\Application\Kernel; use Symfony\Bundle\FrameworkBundle\Console\Application; -use Symfony\Component\Console\Input\ArgvInput; -use Symfony\Component\Debug\Debug; -set_time_limit(0); - -require __DIR__.'/../../../vendor/autoload.php'; - -if (!class_exists(Application::class)) { - throw new RuntimeException('You need to add "symfony/framework-bundle" as a Composer dependency.'); +if (!is_file(dirname(__DIR__).'/../../vendor/autoload_runtime.php')) { + throw new LogicException('Symfony Runtime is missing. Try running "composer require symfony/runtime".'); } -$input = new ArgvInput(); -if (null !== $env = $input->getParameterOption(['--env', '-e'], null, true)) { - putenv('APP_ENV='.$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $env); -} - -if ($input->hasParameterOption('--no-debug', true)) { - putenv('APP_DEBUG='.$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0'); -} - -require dirname(__DIR__).'/config/bootstrap.php'; - -if ($_SERVER['APP_DEBUG']) { - umask(0000); - - if (class_exists(Debug::class)) { - Debug::enable(); - } -} +require_once dirname(__DIR__).'/../../vendor/autoload_runtime.php'; -$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']); -$application = new Application($kernel); -$application->run($input); +return function (array $context) { + return new Application(new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG'])); +}; diff --git a/tests/Application/public/index.php b/tests/Application/public/index.php index 529ed0fa3..92c7cb4d8 100644 --- a/tests/Application/public/index.php +++ b/tests/Application/public/index.php @@ -2,28 +2,10 @@ declare(strict_types=1); -use Symfony\Component\ErrorHandler\Debug; -use Symfony\Component\HttpFoundation\Request; use Tests\BitBag\SyliusCmsPlugin\Application\Kernel; -require dirname(__DIR__) . '/config/bootstrap.php'; +require_once dirname(__DIR__) . '/../../vendor/autoload_runtime.php'; -if ($_SERVER['APP_DEBUG']) { - umask(0000); - - Debug::enable(); -} - -if ($trustedProxies = $_SERVER['TRUSTED_PROXIES'] ?? $_ENV['TRUSTED_PROXIES'] ?? false) { - Request::setTrustedProxies(explode(',', $trustedProxies), Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST); -} - -if ($trustedHosts = $_SERVER['TRUSTED_HOSTS'] ?? $_ENV['TRUSTED_HOSTS'] ?? false) { - Request::setTrustedHosts([$trustedHosts]); -} - -$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']); -$request = Request::createFromGlobals(); -$response = $kernel->handle($request); -$response->send(); -$kernel->terminate($request, $response); +return static function (array $context) { + return new Kernel($context['APP_ENV'], (bool)$context['APP_DEBUG']); +}; From 5da41b5cc5f0af53238bcfdf152cd47f2b32f0b0 Mon Sep 17 00:00:00 2001 From: Francis Hilaire Date: Mon, 13 May 2024 20:51:39 +0200 Subject: [PATCH 18/33] Fix Kernel config --- tests/Application/Kernel.php | 43 ++++++++----------- tests/Application/composer.lock | 18 -------- tests/Application/config/bootstrap.php | 10 +++-- .../Application/config/packages/_sylius.yaml | 1 + tests/Application/config/parameters.yaml | 2 + tests/Application/config/services.yaml | 4 -- tests/Application/config/services_test.yaml | 5 --- 7 files changed, 26 insertions(+), 57 deletions(-) delete mode 100644 tests/Application/composer.lock create mode 100644 tests/Application/config/parameters.yaml diff --git a/tests/Application/Kernel.php b/tests/Application/Kernel.php index 790bd4841..fd5a36f70 100755 --- a/tests/Application/Kernel.php +++ b/tests/Application/Kernel.php @@ -5,11 +5,13 @@ namespace Tests\BitBag\SyliusCmsPlugin\Application; use PSS\SymfonyMockerContainer\DependencyInjection\MockerContainer; -use Sylius\Bundle\CoreBundle\Application\Kernel as SyliusKernel; +use Sylius\Bundle\CoreBundle\SyliusCoreBundle; use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; +use Symfony\Component\Config\Loader\LoaderInterface; +use Symfony\Component\Config\Resource\FileResource; +use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Bundle\BundleInterface; use Symfony\Component\HttpKernel\Kernel as BaseKernel; -use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; final class Kernel extends BaseKernel { @@ -17,16 +19,6 @@ final class Kernel extends BaseKernel private const CONFIG_EXTS = '.{php,xml,yaml,yml}'; - public function getCacheDir(): string - { - return $this->getProjectDir() . '/var/cache/' . $this->environment; - } - - public function getLogDir(): string - { - return $this->getProjectDir() . '/var/log'; - } - public function registerBundles(): iterable { foreach ($this->getConfigurationDirectories() as $confDir) { @@ -38,16 +30,21 @@ public function registerBundles(): iterable } } - protected function configureRoutes(RoutingConfigurator $routes): void + private function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void { - foreach ($this->getConfigurationDirectories() as $confDir) { - $this->loadRoutesConfiguration($routes, $confDir); - } + $container->addResource(new FileResource($this->getProjectDir() . '/config/bundles.php')); + $container->setParameter('container.dumper.inline_class_loader', true); + $confDir = $this->getProjectDir() . '/config'; + + $loader->load($confDir . '/{packages}/*' . self::CONFIG_EXTS, 'glob'); + $loader->load($confDir . '/{packages}/' . $this->environment . '/**/*' . self::CONFIG_EXTS, 'glob'); + $loader->load($confDir . '/{services}' . self::CONFIG_EXTS, 'glob'); + $loader->load($confDir . '/{services}_' . $this->environment . self::CONFIG_EXTS, 'glob'); } protected function getContainerBaseClass(): string { - if ($this->isTestEnvironment() && class_exists(MockerContainer::class)) { + if ($this->isTestEnvironment()) { return MockerContainer::class; } @@ -56,14 +53,7 @@ protected function getContainerBaseClass(): string private function isTestEnvironment(): bool { - return 0 === strpos($this->getEnvironment(), 'test'); - } - - private function loadRoutesConfiguration(RoutingConfigurator $routes, string $confDir): void - { - $routes->import($confDir . '/{routes}/*' . self::CONFIG_EXTS); - $routes->import($confDir . '/{routes}/' . $this->environment . '/**/*' . self::CONFIG_EXTS); - $routes->import($confDir . '/{routes}' . self::CONFIG_EXTS); + return str_starts_with($this->getEnvironment(), 'test'); } /** @@ -71,6 +61,7 @@ private function loadRoutesConfiguration(RoutingConfigurator $routes, string $co */ private function registerBundlesFromFile(string $bundlesFile): iterable { + /** @var array $contents */ $contents = require $bundlesFile; foreach ($contents as $class => $envs) { if (isset($envs['all']) || isset($envs[$this->environment])) { @@ -85,7 +76,7 @@ private function registerBundlesFromFile(string $bundlesFile): iterable private function getConfigurationDirectories(): iterable { yield $this->getProjectDir() . '/config'; - $syliusConfigDir = $this->getProjectDir() . '/config/sylius/' . SyliusKernel::MAJOR_VERSION . '.' . SyliusKernel::MINOR_VERSION; + $syliusConfigDir = $this->getProjectDir() . '/config/sylius/' . SyliusCoreBundle::MAJOR_VERSION . '.' . SyliusCoreBundle::MINOR_VERSION; if (is_dir($syliusConfigDir)) { yield $syliusConfigDir; } diff --git a/tests/Application/composer.lock b/tests/Application/composer.lock deleted file mode 100644 index da8dbee31..000000000 --- a/tests/Application/composer.lock +++ /dev/null @@ -1,18 +0,0 @@ -{ - "_readme": [ - "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", - "This file is @generated automatically" - ], - "content-hash": "75c622fd23b726cd12ac83a6454fec39", - "packages": [], - "packages-dev": [], - "aliases": [], - "minimum-stability": "stable", - "stability-flags": [], - "prefer-stable": false, - "prefer-lowest": false, - "platform": [], - "platform-dev": [], - "plugin-api-version": "2.0.0" -} diff --git a/tests/Application/config/bootstrap.php b/tests/Application/config/bootstrap.php index 2291ab428..c4dd0cd28 100644 --- a/tests/Application/config/bootstrap.php +++ b/tests/Application/config/bootstrap.php @@ -1,7 +1,5 @@ bootEnv(dirname(__DIR__) . '/.env'); + + return; } else { // load all the .env files (new Dotenv())->loadEnv(dirname(__DIR__) . '/.env'); } $_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) ?: 'dev'; -$_SERVER['APP_DEBUG'] = $_SERVER['APP_DEBUG'] ?? $_ENV['APP_DEBUG'] ?? 'prod' !== $_SERVER['APP_ENV']; -$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = (int) $_SERVER['APP_DEBUG'] || filter_var($_SERVER['APP_DEBUG'], \FILTER_VALIDATE_BOOLEAN) ? '1' : '0'; +$_SERVER['APP_DEBUG'] ??= $_ENV['APP_DEBUG'] ?? 'prod' !== $_SERVER['APP_ENV']; +$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = (int) $_SERVER['APP_DEBUG'] || filter_var($_SERVER['APP_DEBUG'], FILTER_VALIDATE_BOOLEAN) ? '1' : '0'; diff --git a/tests/Application/config/packages/_sylius.yaml b/tests/Application/config/packages/_sylius.yaml index fa411e618..ab14c62ef 100644 --- a/tests/Application/config/packages/_sylius.yaml +++ b/tests/Application/config/packages/_sylius.yaml @@ -6,6 +6,7 @@ imports: - { resource: "@SyliusShopBundle/Resources/config/app/config.yml" } - { resource: "@SyliusApiBundle/Resources/config/app/config.yaml" } + - { resource: "../parameters.yaml" } parameters: sylius_core.public_dir: '%kernel.project_dir%/public' diff --git a/tests/Application/config/parameters.yaml b/tests/Application/config/parameters.yaml new file mode 100644 index 000000000..16dc40b75 --- /dev/null +++ b/tests/Application/config/parameters.yaml @@ -0,0 +1,2 @@ +parameters: + locale: en_US diff --git a/tests/Application/config/services.yaml b/tests/Application/config/services.yaml index 615506eb5..e69de29bb 100644 --- a/tests/Application/config/services.yaml +++ b/tests/Application/config/services.yaml @@ -1,4 +0,0 @@ -# Put parameters here that don't need to change on each machine where the app is deployed -# https://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration -parameters: - locale: en_US diff --git a/tests/Application/config/services_test.yaml b/tests/Application/config/services_test.yaml index f90fe4203..a925faa16 100644 --- a/tests/Application/config/services_test.yaml +++ b/tests/Application/config/services_test.yaml @@ -1,8 +1,3 @@ imports: - { resource: "../../Behat/Resources/services.yml" } - { resource: "../../../vendor/sylius/sylius/src/Sylius/Behat/Resources/config/services.xml" } - -# workaround needed for strange "test.client.history" problem -# see https://github.com/FriendsOfBehat/SymfonyExtension/issues/88 -services: - Symfony\Component\BrowserKit\AbstractBrowser: '@test.client' From 1c87a45b9c819946a3fe5e228010d422581d5264 Mon Sep 17 00:00:00 2001 From: Francis Hilaire Date: Mon, 13 May 2024 20:52:13 +0200 Subject: [PATCH 19/33] Update CS build --- .github/workflows/coding_standard.yml | 35 +++++++++------------------ 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/.github/workflows/coding_standard.yml b/.github/workflows/coding_standard.yml index 7cc89e505..1a82a6985 100644 --- a/.github/workflows/coding_standard.yml +++ b/.github/workflows/coding_standard.yml @@ -16,56 +16,43 @@ jobs: tests: runs-on: ubuntu-latest - name: "Sylius ${{ matrix.sylius }}, PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}, MySQL ${{ matrix.mysql }}" + name: "Sylius ${{ matrix.sylius }}, PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}" strategy: fail-fast: false matrix: - php: ["8.0"] - symfony: ["^5.4", "^6.0"] - sylius: ["~1.11.0", "~1.12.0"] - node: ["^14.17.x"] - mysql: ["8.0"] - - exclude: - - sylius: ~1.11.0 - symfony: "^6.0" + php: ["8.1"] + symfony: ["^5.4", "^6.4"] + sylius: ["~1.13.0"] + node: ["20.x"] env: APP_ENV: test - DATABASE_URL: "mysql://root:root@127.0.0.1/sylius?serverVersion=${{ matrix.mysql }}" steps: - - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Setup PHP uses: shivammathur/setup-php@v2 with: php-version: "${{ matrix.php }}" extensions: intl - tools: symfony + tools: flex, symfony coverage: none - name: Get Composer cache directory id: composer-cache - run: echo "::set-output name=dir::$(composer config cache-files-dir)" + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - name: Cache Composer - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json **/composer.lock') }} restore-keys: | ${{ runner.os }}-php-${{ matrix.php }}-composer- - - - name: Restrict Symfony version - if: matrix.symfony != '' - run: | - composer global config --no-plugins allow-plugins.symfony/flex true - composer global require --no-progress --no-scripts --no-plugins "symfony/flex:^1.10" - composer config extra.symfony.require "${{ matrix.symfony }}" - name: Restrict Sylius version if: matrix.sylius != '' @@ -74,6 +61,8 @@ jobs: - name: Install PHP dependencies run: composer install --no-interaction + env: + SYMFONY_REQUIRE: ${{ matrix.symfony }} - name: Run PHPStan @@ -92,4 +81,4 @@ jobs: SLACK_MESSAGE: ':x:' SLACK_TITLE: Failed build on ${{ github.event.repository.name }} repository SLACK_USERNAME: ${{ secrets.FAILED_BUILD_SLACK_USERNAME }} - SLACK_WEBHOOK: ${{ secrets.FAILED_BUILD_SLACK_WEBHOOK }} \ No newline at end of file + SLACK_WEBHOOK: ${{ secrets.FAILED_BUILD_SLACK_WEBHOOK }} From 287b1d60982ab748d63aae294265c32ede0e1e9c Mon Sep 17 00:00:00 2001 From: Francis Hilaire Date: Mon, 13 May 2024 20:59:22 +0200 Subject: [PATCH 20/33] Update ecs config --- ecs.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ecs.php b/ecs.php index 022736f6b..e0c1045ae 100644 --- a/ecs.php +++ b/ecs.php @@ -3,14 +3,16 @@ declare(strict_types=1); use Symplify\EasyCodingStandard\Config\ECSConfig; -use Symplify\EasyCodingStandard\ValueObject\Option; return static function (ECSConfig $config): void { $config->import('vendor/bitbag/coding-standard/ecs.php'); - $parameters = $config->parameters(); - $parameters->set(Option::PATHS, [ + $config->paths([ __DIR__ . '/src', __DIR__ . '/tests', ]); + $config->skip([ + '**/var/*', + '**/node_modules/*', + ]); }; From 74355b4c62188a4aa176ce2ee8cbcf427753e6c6 Mon Sep 17 00:00:00 2001 From: Francis Hilaire Date: Mon, 13 May 2024 20:59:27 +0200 Subject: [PATCH 21/33] ECS fix --- tests/Application/config/bootstrap.php | 4 +++- tests/Application/public/index.php | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/Application/config/bootstrap.php b/tests/Application/config/bootstrap.php index c4dd0cd28..d2199243a 100644 --- a/tests/Application/config/bootstrap.php +++ b/tests/Application/config/bootstrap.php @@ -1,5 +1,7 @@ Date: Mon, 13 May 2024 21:01:08 +0200 Subject: [PATCH 22/33] Fix phpstan command line --- .github/workflows/coding_standard.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coding_standard.yml b/.github/workflows/coding_standard.yml index 1a82a6985..25b87612c 100644 --- a/.github/workflows/coding_standard.yml +++ b/.github/workflows/coding_standard.yml @@ -66,7 +66,7 @@ jobs: - name: Run PHPStan - run: vendor/bin/phpstan analyse -c phpstan.neon -l 8 src/ + run: vendor/bin/phpstan analyse -l 8 src/ - name: Run ECS run: vendor/bin/ecs From 95cf56f229bae5af3a332a20d4665619c2ee206d Mon Sep 17 00:00:00 2001 From: Francis Hilaire Date: Mon, 13 May 2024 21:23:51 +0200 Subject: [PATCH 23/33] Fix PHPStan and update conf --- .github/workflows/coding_standard.yml | 2 +- composer.json | 2 +- phpstan.neon.dist | 12 ++++++------ src/Twig/Parser/ContentParser.php | 3 ++- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/coding_standard.yml b/.github/workflows/coding_standard.yml index 25b87612c..dff8e5644 100644 --- a/.github/workflows/coding_standard.yml +++ b/.github/workflows/coding_standard.yml @@ -66,7 +66,7 @@ jobs: - name: Run PHPStan - run: vendor/bin/phpstan analyse -l 8 src/ + run: vendor/bin/phpstan analyse - name: Run ECS run: vendor/bin/ecs diff --git a/composer.json b/composer.json index 5a22567d9..1905ccfd7 100755 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "behat/behat": "^3.6.1", "behat/mink-selenium2-driver": "^1.4", "dbrekelmans/bdi": "^1.1", - "bitbag/coding-standard": "^2.0", + "bitbag/coding-standard": "^3.0", "dmore/behat-chrome-extension": "^1.3", "dmore/chrome-mink-driver": "^2.7", "friends-of-behat/mink": "^1.8", diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 0c2a35c3c..109ffc4ad 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -1,11 +1,10 @@ -includes: - - vendor/bitbag/coding-standard/phpstan.neon parameters: level: 8 reportUnmatchedIgnoredErrors: false - checkMissingIterableValueType: false - checkGenericClassInNonGenericObjectType: false - excludes_analyse: + paths: + - src + + excludePaths: # Sitemap dependent providers - 'src/SitemapProvider' - 'src/Importer/AbstractImporter' @@ -13,5 +12,6 @@ parameters: - 'tests/Fixture/PageFixtureTest.php' - 'src/Controller/Helper' ignoreErrors: + - identifier: missingType.iterableValue + - identifier: missingType.generics - '#.*NodeParentInterface.*#' - - '#.*PHPDoc tag @throws with type Exception|Psr\Container\ContainerExceptionInterface is not subtype of Throwable.*#' diff --git a/src/Twig/Parser/ContentParser.php b/src/Twig/Parser/ContentParser.php index ea4d8c375..8f02b0654 100644 --- a/src/Twig/Parser/ContentParser.php +++ b/src/Twig/Parser/ContentParser.php @@ -11,6 +11,7 @@ namespace BitBag\SyliusCmsPlugin\Twig\Parser; use Twig\Environment; +use Twig\TwigFunction; use Webmozart\Assert\Assert; final class ContentParser implements ContentParserInterface @@ -70,7 +71,7 @@ private function callFunction( array $arguments, ): string { Assert::keyExists($functions, $functionName, sprintf('Function %s does not exist!', $functionName)); - /** @var \Twig_Function $function */ + /** @var TwigFunction $function */ $function = $functions[$functionName]; $callable = $function->getCallable(); Assert::isArray($callable, sprintf('Function with name "%s" is not callable', $functionName)); From ed222285bf5a96eeac86a7eb11a7310b6edb5fa8 Mon Sep 17 00:00:00 2001 From: Francis Hilaire Date: Mon, 13 May 2024 21:24:44 +0200 Subject: [PATCH 24/33] Fix ECS --- src/Controller/Action/Admin/ImportDataAction.php | 2 +- src/Controller/Action/Admin/ProductSearchAction.php | 2 +- src/Controller/Action/Admin/TaxonSearchAction.php | 2 +- src/Controller/Action/Admin/UploadEditorImageAction.php | 2 +- src/Entity/FrequentlyAskedQuestion.php | 4 ++-- src/Fixture/Factory/BlockFixtureFactory.php | 2 +- .../Factory/FrequentlyAskedQuestionFixtureFactory.php | 4 ++-- src/Fixture/Factory/MediaFixtureFactory.php | 2 +- src/Fixture/Factory/PageFixtureFactory.php | 8 ++++---- src/Fixture/Factory/SectionFixtureFactory.php | 2 +- src/Form/Type/MediaAutocompleteChoiceType.php | 2 +- src/Form/Type/MediaType.php | 2 +- src/Form/Type/SectionAutocompleteChoiceType.php | 2 +- src/Importer/AbstractImporter.php | 2 +- src/Importer/BlockImporter.php | 2 +- src/Importer/MediaImporter.php | 2 +- src/Importer/PageImporter.php | 4 ++-- src/MediaProvider/GenericProvider.php | 4 ++-- src/MediaProvider/ProviderInterface.php | 2 +- src/Processor/ImportProcessor.php | 2 +- src/Repository/BlockRepository.php | 4 ++-- src/Repository/BlockRepositoryInterface.php | 4 ++-- src/Repository/MediaRepository.php | 8 ++++---- src/Repository/MediaRepositoryInterface.php | 6 +++--- src/Repository/PageRepository.php | 6 +++--- src/Repository/PageRepositoryInterface.php | 6 +++--- src/Repository/SectionRepository.php | 2 +- src/Resolver/BlockResourceResolver.php | 2 +- src/Resolver/MediaResourceResolver.php | 2 +- src/Resolver/PageResourceResolver.php | 2 +- src/Resolver/ResourceResolver.php | 2 +- src/Twig/Parser/ContentParser.php | 2 +- src/Twig/Runtime/RenderLinkRuntime.php | 4 ++-- src/Twig/Runtime/RenderLinkRuntimeInterface.php | 2 +- src/Twig/Runtime/RenderProductPagesRuntime.php | 2 +- src/Uploader/MediaUploader.php | 2 +- tests/Behat/Context/Api/BlockContext.php | 2 +- tests/Behat/Context/Api/MediaContext.php | 2 +- tests/Behat/Context/Api/SectionContext.php | 2 +- tests/Behat/Context/Setup/BlockContext.php | 4 ++-- .../Context/Setup/FrequentlyAskedQuestionContext.php | 4 ++-- tests/Behat/Context/Setup/MediaContext.php | 4 ++-- tests/Behat/Context/Setup/PageContext.php | 4 ++-- tests/Behat/Context/Setup/SectionContext.php | 2 +- tests/Behat/Context/Ui/Admin/BlockContext.php | 2 +- .../Context/Ui/Admin/FrequentlyAskedQuestionContext.php | 2 +- tests/Behat/Context/Ui/Admin/MediaContext.php | 2 +- tests/Behat/Context/Ui/Admin/PageContext.php | 2 +- tests/Behat/Context/Ui/Admin/SectionContext.php | 2 +- tests/Behat/Context/Ui/Shop/PageContext.php | 2 +- tests/Behat/Service/FormHelper.php | 2 +- tests/Behat/Service/WysiwygHelper.php | 2 +- tests/Functional/FunctionalTestCase.php | 2 +- 53 files changed, 76 insertions(+), 76 deletions(-) diff --git a/src/Controller/Action/Admin/ImportDataAction.php b/src/Controller/Action/Admin/ImportDataAction.php index d07601f03..704d32eac 100644 --- a/src/Controller/Action/Admin/ImportDataAction.php +++ b/src/Controller/Action/Admin/ImportDataAction.php @@ -51,7 +51,7 @@ public function __construct( FormErrorsFlashHelperInterface $formErrorsFlashHelper, TranslatorInterface $translator, Environment $twig, - ) { + ) { $this->importProcessor = $importProcessor; $this->formFactory = $formFactory; $this->requestStack = $requestStack; diff --git a/src/Controller/Action/Admin/ProductSearchAction.php b/src/Controller/Action/Admin/ProductSearchAction.php index 2181040c9..0711eb890 100644 --- a/src/Controller/Action/Admin/ProductSearchAction.php +++ b/src/Controller/Action/Admin/ProductSearchAction.php @@ -32,7 +32,7 @@ public function __construct( ProductRepositoryInterface $productRepository, LocaleContextInterface $localeContext, ViewHandler $viewHandler, - ) { + ) { $this->productRepository = $productRepository; $this->localeContext = $localeContext; $this->viewHandler = $viewHandler; diff --git a/src/Controller/Action/Admin/TaxonSearchAction.php b/src/Controller/Action/Admin/TaxonSearchAction.php index a6a2fd36e..eeefdd9c8 100644 --- a/src/Controller/Action/Admin/TaxonSearchAction.php +++ b/src/Controller/Action/Admin/TaxonSearchAction.php @@ -32,7 +32,7 @@ public function __construct( TaxonRepositoryInterface $taxonRepository, LocaleContextInterface $localeContext, ViewHandler $viewHandler, - ) { + ) { $this->taxonRepository = $taxonRepository; $this->localeContext = $localeContext; $this->viewHandler = $viewHandler; diff --git a/src/Controller/Action/Admin/UploadEditorImageAction.php b/src/Controller/Action/Admin/UploadEditorImageAction.php index 610398341..198a81490 100644 --- a/src/Controller/Action/Admin/UploadEditorImageAction.php +++ b/src/Controller/Action/Admin/UploadEditorImageAction.php @@ -36,7 +36,7 @@ public function __construct( MediaProviderResolverInterface $mediaProviderResolver, MediaRepositoryInterface $mediaRepository, FactoryInterface $mediaFactory, - ) { + ) { $this->mediaProviderResolver = $mediaProviderResolver; $this->mediaRepository = $mediaRepository; $this->mediaFactory = $mediaFactory; diff --git a/src/Entity/FrequentlyAskedQuestion.php b/src/Entity/FrequentlyAskedQuestion.php index ac5fcadbf..517ccc62c 100755 --- a/src/Entity/FrequentlyAskedQuestion.php +++ b/src/Entity/FrequentlyAskedQuestion.php @@ -19,8 +19,8 @@ class FrequentlyAskedQuestion implements FrequentlyAskedQuestionInterface use ChannelsAwareTrait; use ToggleableTrait, TranslatableTrait { - __construct as private initializeTranslationsCollection; - } + __construct as private initializeTranslationsCollection; + } /** @var int */ protected $id; diff --git a/src/Fixture/Factory/BlockFixtureFactory.php b/src/Fixture/Factory/BlockFixtureFactory.php index 5b71860c5..7c8115877 100755 --- a/src/Fixture/Factory/BlockFixtureFactory.php +++ b/src/Fixture/Factory/BlockFixtureFactory.php @@ -36,7 +36,7 @@ public function __construct( private TaxonsAssignerInterface $taxonsAssigner, private SectionsAssignerInterface $sectionsAssigner, private ChannelsAssignerInterface $channelAssigner, - ) { + ) { } public function load(array $data): void diff --git a/src/Fixture/Factory/FrequentlyAskedQuestionFixtureFactory.php b/src/Fixture/Factory/FrequentlyAskedQuestionFixtureFactory.php index 082fe5170..1dd5edfa3 100755 --- a/src/Fixture/Factory/FrequentlyAskedQuestionFixtureFactory.php +++ b/src/Fixture/Factory/FrequentlyAskedQuestionFixtureFactory.php @@ -23,7 +23,7 @@ public function __construct( private FactoryInterface $frequentlyAskedQuestionTranslationFactory, private FrequentlyAskedQuestionRepositoryInterface $frequentlyAskedQuestionRepository, private ChannelsAssignerInterface $channelAssigner, - ) { + ) { } public function load(array $data): void @@ -52,7 +52,7 @@ private function createFrequentlyAskedQuestion( string $code, array $frequentlyAskedQuestionData, int $position, - ): void { + ): void { /** @var FrequentlyAskedQuestionInterface $frequentlyAskedQuestion */ $frequentlyAskedQuestion = $this->frequentlyAskedQuestionFactory->createNew(); diff --git a/src/Fixture/Factory/MediaFixtureFactory.php b/src/Fixture/Factory/MediaFixtureFactory.php index 81e1214c0..153c44c0f 100644 --- a/src/Fixture/Factory/MediaFixtureFactory.php +++ b/src/Fixture/Factory/MediaFixtureFactory.php @@ -30,7 +30,7 @@ public function __construct( private ProductsAssignerInterface $productsAssigner, private SectionsAssignerInterface $sectionsAssigner, private ChannelsAssignerInterface $channelAssigner, - ) { + ) { } public function load(array $data): void diff --git a/src/Fixture/Factory/PageFixtureFactory.php b/src/Fixture/Factory/PageFixtureFactory.php index c7c125cd0..3a6827fd3 100755 --- a/src/Fixture/Factory/PageFixtureFactory.php +++ b/src/Fixture/Factory/PageFixtureFactory.php @@ -42,7 +42,7 @@ public function __construct( private ProductRepositoryInterface $productRepository, private LocaleContextInterface $localeContext, private ChannelRepositoryInterface $channelRepository, - ) { + ) { } public function load(array $data): void @@ -71,7 +71,7 @@ private function createPage( string $code, array $pageData, bool $generateSlug = false, - ): void { + ): void { /** @var PageInterface $page */ $page = $this->pageFactory->createNew(); $products = $pageData['products']; @@ -124,7 +124,7 @@ private function resolveProductsForChannels( PageInterface $page, int $limit, array $channelCodes, - ): void { + ): void { foreach ($channelCodes as $channelCode) { /** @var ChannelInterface|null $channel */ $channel = $this->channelRepository->findOneByCode($channelCode); @@ -138,7 +138,7 @@ private function resolveProductsForChannel( PageInterface $page, int $limit, ChannelInterface $channel, - ): void { + ): void { $products = $this->productRepository->findLatestByChannel( $channel, $this->localeContext->getLocaleCode(), diff --git a/src/Fixture/Factory/SectionFixtureFactory.php b/src/Fixture/Factory/SectionFixtureFactory.php index 4465b4631..32ccd2d06 100755 --- a/src/Fixture/Factory/SectionFixtureFactory.php +++ b/src/Fixture/Factory/SectionFixtureFactory.php @@ -21,7 +21,7 @@ public function __construct( private FactoryInterface $sectionFactory, private FactoryInterface $sectionTranslationFactory, private SectionRepositoryInterface $sectionRepository, - ) { + ) { } public function load(array $data): void diff --git a/src/Form/Type/MediaAutocompleteChoiceType.php b/src/Form/Type/MediaAutocompleteChoiceType.php index 49c28e018..951688e39 100644 --- a/src/Form/Type/MediaAutocompleteChoiceType.php +++ b/src/Form/Type/MediaAutocompleteChoiceType.php @@ -40,7 +40,7 @@ public function buildView( FormView $view, FormInterface $form, array $options, - ): void { + ): void { $view->vars['remote_criteria_type'] = 'contains'; $view->vars['remote_criteria_name'] = 'phrase'; $view->vars['media_type'] = $options['media_type']; diff --git a/src/Form/Type/MediaType.php b/src/Form/Type/MediaType.php index 83524b12d..7671a17d9 100644 --- a/src/Form/Type/MediaType.php +++ b/src/Form/Type/MediaType.php @@ -30,7 +30,7 @@ public function __construct( string $dataClass, array $validationGroups = [], array $providers = [], - ) { + ) { parent::__construct($dataClass, $validationGroups); $this->providers = $providers; diff --git a/src/Form/Type/SectionAutocompleteChoiceType.php b/src/Form/Type/SectionAutocompleteChoiceType.php index 9b4928619..ec57d6918 100755 --- a/src/Form/Type/SectionAutocompleteChoiceType.php +++ b/src/Form/Type/SectionAutocompleteChoiceType.php @@ -31,7 +31,7 @@ public function buildView( FormView $view, FormInterface $form, array $options, - ): void { + ): void { $view->vars['remote_criteria_type'] = 'contains'; $view->vars['remote_criteria_name'] = 'phrase'; } diff --git a/src/Importer/AbstractImporter.php b/src/Importer/AbstractImporter.php index 042767f2d..52147a013 100755 --- a/src/Importer/AbstractImporter.php +++ b/src/Importer/AbstractImporter.php @@ -36,7 +36,7 @@ protected function getTranslatableColumnValue( string $column, $locale, array $row, - ) { + ) { $column = str_replace('__locale__', '_' . $locale, $column); if (array_key_exists($column, $row)) { diff --git a/src/Importer/BlockImporter.php b/src/Importer/BlockImporter.php index c4cc09613..d0e941366 100644 --- a/src/Importer/BlockImporter.php +++ b/src/Importer/BlockImporter.php @@ -30,7 +30,7 @@ public function __construct( private ImporterProductsResolverInterface $importerProductsResolver, ValidatorInterface $validator, private BlockRepositoryInterface $blockRepository, - ) { + ) { parent::__construct($validator); } diff --git a/src/Importer/MediaImporter.php b/src/Importer/MediaImporter.php index d70848c8b..e5e602d65 100644 --- a/src/Importer/MediaImporter.php +++ b/src/Importer/MediaImporter.php @@ -28,7 +28,7 @@ public function __construct( private ImporterProductsResolverInterface $importerProductsResolver, ValidatorInterface $validator, private MediaRepositoryInterface $mediaRepository, - ) { + ) { parent::__construct($validator); } diff --git a/src/Importer/PageImporter.php b/src/Importer/PageImporter.php index 531b03e39..bcb24b48c 100644 --- a/src/Importer/PageImporter.php +++ b/src/Importer/PageImporter.php @@ -39,7 +39,7 @@ public function __construct( private ImporterProductsResolverInterface $importerProductsResolver, ValidatorInterface $validator, private EntityManagerInterface $entityManager, - ) { + ) { parent::__construct($validator); } @@ -94,7 +94,7 @@ private function resolveImage( string $url, string $locale, string $imageCode, - ): void { + ): void { $downloadedImage = $this->imageDownloader->download($url); /** @var MediaInterface $image */ diff --git a/src/MediaProvider/GenericProvider.php b/src/MediaProvider/GenericProvider.php index 1b111cdcd..465b0368e 100755 --- a/src/MediaProvider/GenericProvider.php +++ b/src/MediaProvider/GenericProvider.php @@ -21,7 +21,7 @@ public function __construct( private Environment $twigEngine, private string $template, private string $pathPrefix, - ) { + ) { } public function getTemplate(): string @@ -33,7 +33,7 @@ public function render( MediaInterface $media, ?string $template = null, array $options = [], - ): string { + ): string { return $this->twigEngine->render($template ?? $this->template, array_merge(['media' => $media], $options)); } diff --git a/src/MediaProvider/ProviderInterface.php b/src/MediaProvider/ProviderInterface.php index 7c46af390..a793fbf09 100644 --- a/src/MediaProvider/ProviderInterface.php +++ b/src/MediaProvider/ProviderInterface.php @@ -20,7 +20,7 @@ public function render( MediaInterface $media, ?string $template = null, array $options = [], - ): string; + ): string; public function upload(MediaInterface $media): void; } diff --git a/src/Processor/ImportProcessor.php b/src/Processor/ImportProcessor.php index 1f660b78b..2b32379a9 100644 --- a/src/Processor/ImportProcessor.php +++ b/src/Processor/ImportProcessor.php @@ -21,7 +21,7 @@ public function __construct( private ImporterChainInterface $importerChain, private ReaderInterface $reader, private EntityManagerInterface $entityManager, - ) { + ) { } public function process(string $resourceCode, string $filePath): void diff --git a/src/Repository/BlockRepository.php b/src/Repository/BlockRepository.php index 5a36615eb..143e8066f 100755 --- a/src/Repository/BlockRepository.php +++ b/src/Repository/BlockRepository.php @@ -43,7 +43,7 @@ public function findBySectionCode( string $sectionCode, string $localeCode, string $channelCode, - ): array { + ): array { return $this->createQueryBuilder('o') ->leftJoin('o.translations', 'translation') ->innerJoin('o.sections', 'section') @@ -64,7 +64,7 @@ public function findByProductCode( string $productCode, string $localeCode, string $channelCode, - ): array { + ): array { return $this->createQueryBuilder('o') ->leftJoin('o.translations', 'translation') ->innerJoin('o.products', 'product') diff --git a/src/Repository/BlockRepositoryInterface.php b/src/Repository/BlockRepositoryInterface.php index 0488b33ef..53bb70c68 100755 --- a/src/Repository/BlockRepositoryInterface.php +++ b/src/Repository/BlockRepositoryInterface.php @@ -24,11 +24,11 @@ public function findBySectionCode( string $sectionCode, string $localeCode, string $channelCode, - ): array; + ): array; public function findByProductCode( string $productCode, string $localeCode, string $channelCode, - ): array; + ): array; } diff --git a/src/Repository/MediaRepository.php b/src/Repository/MediaRepository.php index 5b1391da6..e469d8844 100755 --- a/src/Repository/MediaRepository.php +++ b/src/Repository/MediaRepository.php @@ -28,7 +28,7 @@ public function findOneEnabledByCode( string $code, string $localeCode, string $channelCode, - ): ?MediaInterface { + ): ?MediaInterface { return $this->createQueryBuilder('o') ->leftJoin('o.translations', 'translation') ->innerJoin('o.channels', 'channels') @@ -48,7 +48,7 @@ public function findBySectionCode( string $sectionCode, string $localeCode, string $channelCode, - ): array { + ): array { return $this->createQueryBuilder('o') ->leftJoin('o.translations', 'translation') ->innerJoin('o.sections', 'section') @@ -62,14 +62,14 @@ public function findBySectionCode( ->setParameter('channelCode', $channelCode) ->getQuery() ->getResult() - ; + ; } public function findByProductCode( string $productCode, string $localeCode, string $channelCode, - ): array { + ): array { return $this->createQueryBuilder('o') ->leftJoin('o.translations', 'translation') ->innerJoin('o.products', 'product') diff --git a/src/Repository/MediaRepositoryInterface.php b/src/Repository/MediaRepositoryInterface.php index 27b6ae943..17505e3cf 100755 --- a/src/Repository/MediaRepositoryInterface.php +++ b/src/Repository/MediaRepositoryInterface.php @@ -22,17 +22,17 @@ public function findOneEnabledByCode( string $code, string $localeCode, string $channelCode, - ): ?MediaInterface; + ): ?MediaInterface; public function findBySectionCode( string $sectionCode, string $localeCode, string $channelCode, - ): array; + ): array; public function findByProductCode( string $productCode, string $localeCode, string $channelCode, - ): array; + ): array; } diff --git a/src/Repository/PageRepository.php b/src/Repository/PageRepository.php index 94fd2d201..ebfa26e1a 100755 --- a/src/Repository/PageRepository.php +++ b/src/Repository/PageRepository.php @@ -57,7 +57,7 @@ public function findOneEnabledBySlugAndChannelCode( string $slug, ?string $localeCode, string $channelCode, - ): ?PageInterface { + ): ?PageInterface { return $this->createQueryBuilder('o') ->leftJoin('o.translations', 'translation') ->innerJoin('o.channels', 'channels') @@ -105,7 +105,7 @@ public function findByProduct( ProductInterface $product, string $channelCode, ?\DateTimeInterface $date = null, - ): array { + ): array { $qb = $this->createQueryBuilder('o') ->innerJoin('o.products', 'product') ->innerJoin('o.channels', 'channel') @@ -131,7 +131,7 @@ public function findByProductAndSectionCode( string $sectionCode, string $channelCode, ?\DateTimeInterface $date = null, - ): array { + ): array { $qb = $this->createQueryBuilder('o') ->innerJoin('o.products', 'product') ->innerJoin('o.sections', 'section') diff --git a/src/Repository/PageRepositoryInterface.php b/src/Repository/PageRepositoryInterface.php index 36f81bb65..afa541021 100755 --- a/src/Repository/PageRepositoryInterface.php +++ b/src/Repository/PageRepositoryInterface.php @@ -27,7 +27,7 @@ public function findOneEnabledBySlugAndChannelCode( string $slug, ?string $localeCode, string $channelCode, - ): ?PageInterface; + ): ?PageInterface; public function createShopListQueryBuilder(string $sectionCode, string $channelCode): QueryBuilder; @@ -37,12 +37,12 @@ public function findByProduct( ProductInterface $product, string $channelCode, ?\DateTimeInterface $date, - ): array; + ): array; public function findByProductAndSectionCode( ProductInterface $product, string $sectionCode, string $channelCode, ?\DateTimeInterface $date, - ): array; + ): array; } diff --git a/src/Repository/SectionRepository.php b/src/Repository/SectionRepository.php index 6d4d89e79..2c1791279 100755 --- a/src/Repository/SectionRepository.php +++ b/src/Repository/SectionRepository.php @@ -75,6 +75,6 @@ public function findByCodesAndLocale(string $codes, string $localeCode): array ->setParameter('localeCode', $localeCode) ->getQuery() ->getResult() - ; + ; } } diff --git a/src/Resolver/BlockResourceResolver.php b/src/Resolver/BlockResourceResolver.php index 41ffc67eb..baf6ab6a8 100755 --- a/src/Resolver/BlockResourceResolver.php +++ b/src/Resolver/BlockResourceResolver.php @@ -22,7 +22,7 @@ public function __construct( private BlockRepositoryInterface $blockRepository, private LoggerInterface $logger, private ChannelContextInterface $channelContext, - ) { + ) { } public function findOrLog(string $code): ?BlockInterface diff --git a/src/Resolver/MediaResourceResolver.php b/src/Resolver/MediaResourceResolver.php index 2c58f0ebe..c396aa6d4 100755 --- a/src/Resolver/MediaResourceResolver.php +++ b/src/Resolver/MediaResourceResolver.php @@ -24,7 +24,7 @@ public function __construct( private LocaleContextInterface $localeContext, private ChannelContextInterface $channelContext, private LoggerInterface $logger, - ) { + ) { } public function findOrLog(string $code): ?MediaInterface diff --git a/src/Resolver/PageResourceResolver.php b/src/Resolver/PageResourceResolver.php index c7152a7a3..a8ae222cc 100755 --- a/src/Resolver/PageResourceResolver.php +++ b/src/Resolver/PageResourceResolver.php @@ -21,7 +21,7 @@ public function __construct( private PageRepositoryInterface $pageRepository, private LocaleContextInterface $localeContext, private LoggerInterface $logger, - ) { + ) { } public function findOrLog(string $code): ?PageInterface diff --git a/src/Resolver/ResourceResolver.php b/src/Resolver/ResourceResolver.php index ebe9e5c31..2076d55ad 100644 --- a/src/Resolver/ResourceResolver.php +++ b/src/Resolver/ResourceResolver.php @@ -21,7 +21,7 @@ public function __construct( private RepositoryInterface $repository, private FactoryInterface $factory, private string $uniqueColumn, - ) { + ) { } /** diff --git a/src/Twig/Parser/ContentParser.php b/src/Twig/Parser/ContentParser.php index 8f02b0654..0104a4171 100644 --- a/src/Twig/Parser/ContentParser.php +++ b/src/Twig/Parser/ContentParser.php @@ -69,7 +69,7 @@ private function callFunction( array $functions, string $functionName, array $arguments, - ): string { + ): string { Assert::keyExists($functions, $functionName, sprintf('Function %s does not exist!', $functionName)); /** @var TwigFunction $function */ $function = $functions[$functionName]; diff --git a/src/Twig/Runtime/RenderLinkRuntime.php b/src/Twig/Runtime/RenderLinkRuntime.php index 003512a80..0d051aa8c 100644 --- a/src/Twig/Runtime/RenderLinkRuntime.php +++ b/src/Twig/Runtime/RenderLinkRuntime.php @@ -24,7 +24,7 @@ public function __construct( private PageRepositoryInterface $pageRepository, private RouterInterface $router, private string $defaultTemplate, - ) { + ) { } public function renderLinkForCode( @@ -32,7 +32,7 @@ public function renderLinkForCode( string $code, array $options = [], ?string $template = null, - ): string { + ): string { $page = $this->pageRepository->findOneEnabledByCode($code, $this->localeContext->getLocaleCode()); return $environment->render($template ?? $this->defaultTemplate, [ diff --git a/src/Twig/Runtime/RenderLinkRuntimeInterface.php b/src/Twig/Runtime/RenderLinkRuntimeInterface.php index 616791859..c10624dd3 100644 --- a/src/Twig/Runtime/RenderLinkRuntimeInterface.php +++ b/src/Twig/Runtime/RenderLinkRuntimeInterface.php @@ -20,7 +20,7 @@ public function renderLinkForCode( string $code, array $options = [], ?string $template = null, - ): string; + ): string; public function getLinkForCode(string $code, array $options = []): string; } diff --git a/src/Twig/Runtime/RenderProductPagesRuntime.php b/src/Twig/Runtime/RenderProductPagesRuntime.php index 62a555212..ad8f0cdf7 100644 --- a/src/Twig/Runtime/RenderProductPagesRuntime.php +++ b/src/Twig/Runtime/RenderProductPagesRuntime.php @@ -24,7 +24,7 @@ public function __construct( private ChannelContextInterface $channelContext, private Environment $templatingEngine, private SectionsSorterInterface $sectionsSorter, - ) { + ) { } public function renderProductPages(ProductInterface $product, string $sectionCode = null): string diff --git a/src/Uploader/MediaUploader.php b/src/Uploader/MediaUploader.php index bb2e0abe9..a238dd028 100644 --- a/src/Uploader/MediaUploader.php +++ b/src/Uploader/MediaUploader.php @@ -79,7 +79,7 @@ private function expandPath( string $path, string $pathPrefix, ?string $originalName = null, - ): string { + ): string { return sprintf( '%s/%s/%s/%s', $pathPrefix, diff --git a/tests/Behat/Context/Api/BlockContext.php b/tests/Behat/Context/Api/BlockContext.php index 9822835dc..836397c95 100644 --- a/tests/Behat/Context/Api/BlockContext.php +++ b/tests/Behat/Context/Api/BlockContext.php @@ -52,8 +52,8 @@ public function iShouldSeeBlocksInTheList(int $count): void } /** - * @Then I should see block with code :block * @Given I view block with code :block + * @Then I should see block with code :block */ public function iShouldSeeBlockWithCode(string $code): void { diff --git a/tests/Behat/Context/Api/MediaContext.php b/tests/Behat/Context/Api/MediaContext.php index 5b936aa1c..463f7741e 100644 --- a/tests/Behat/Context/Api/MediaContext.php +++ b/tests/Behat/Context/Api/MediaContext.php @@ -53,8 +53,8 @@ public function iShouldSeeMediaInTheList(int $count): void } /** - * @Then I should see media with code :media * @Given I view media with code :media + * @Then I should see media with code :media */ public function iShouldSeeTheMedia(MediaInterface $media): void { diff --git a/tests/Behat/Context/Api/SectionContext.php b/tests/Behat/Context/Api/SectionContext.php index 8e0a993fe..a13e610eb 100644 --- a/tests/Behat/Context/Api/SectionContext.php +++ b/tests/Behat/Context/Api/SectionContext.php @@ -53,8 +53,8 @@ public function iShouldSeeSectionsInTheList(int $count): void } /** - * @Then I should see section with code :section * @Given I view section with code :section + * @Then I should see section with code :section */ public function iShouldSeeSectionWithCode(SectionInterface $section): void { diff --git a/tests/Behat/Context/Setup/BlockContext.php b/tests/Behat/Context/Setup/BlockContext.php index ba142492d..68804109c 100755 --- a/tests/Behat/Context/Setup/BlockContext.php +++ b/tests/Behat/Context/Setup/BlockContext.php @@ -37,7 +37,7 @@ public function __construct( RandomStringGeneratorInterface $randomStringGenerator, FactoryInterface $blockFactory, BlockRepositoryInterface $blockRepository, - ) { + ) { $this->sharedStorage = $sharedStorage; $this->randomStringGenerator = $randomStringGenerator; $this->blockFactory = $blockFactory; @@ -79,7 +79,7 @@ private function createBlock( ?string $code = null, ?string $content = null, ChannelInterface $channel = null, - ): BlockInterface { + ): BlockInterface { /** @var BlockInterface $block */ $block = $this->blockFactory->createNew(); diff --git a/tests/Behat/Context/Setup/FrequentlyAskedQuestionContext.php b/tests/Behat/Context/Setup/FrequentlyAskedQuestionContext.php index b01ebab4b..c7f7ac1b2 100755 --- a/tests/Behat/Context/Setup/FrequentlyAskedQuestionContext.php +++ b/tests/Behat/Context/Setup/FrequentlyAskedQuestionContext.php @@ -34,7 +34,7 @@ public function __construct( RandomStringGeneratorInterface $randomStringGenerator, FactoryInterface $frequentlyAskedQuestionFactory, FrequentlyAskedQuestionRepositoryInterface $frequentlyAskedQuestionRepository, - ) { + ) { $this->sharedStorage = $sharedStorage; $this->randomStringGenerator = $randomStringGenerator; $this->frequentlyAskedQuestionFactory = $frequentlyAskedQuestionFactory; @@ -94,7 +94,7 @@ private function createFrequentlyAskedQuestion( int $position = null, bool $prefixQuestionWithPosition = false, ChannelInterface $channel = null, - ): FrequentlyAskedQuestionInterface { + ): FrequentlyAskedQuestionInterface { /** @var FrequentlyAskedQuestionInterface $frequentlyAskedQuestion */ $frequentlyAskedQuestion = $this->frequentlyAskedQuestionFactory->createNew(); diff --git a/tests/Behat/Context/Setup/MediaContext.php b/tests/Behat/Context/Setup/MediaContext.php index de7e6f6c9..3d856a233 100755 --- a/tests/Behat/Context/Setup/MediaContext.php +++ b/tests/Behat/Context/Setup/MediaContext.php @@ -58,7 +58,7 @@ public function __construct( ProductRepositoryInterface $productRepository, SectionRepositoryInterface $sectionRepository, MediaProviderResolverInterface $mediaProviderResolver, - ) { + ) { $this->sharedStorage = $sharedStorage; $this->randomStringGenerator = $randomStringGenerator; $this->mediaFactory = $mediaFactory; @@ -99,7 +99,7 @@ private function createMedia( ?string $content = null, ?string $fileType = null, ChannelInterface $channel = null, - ): MediaInterface { + ): MediaInterface { /** @var MediaInterface $media */ $media = $this->mediaFactory->createNew(); diff --git a/tests/Behat/Context/Setup/PageContext.php b/tests/Behat/Context/Setup/PageContext.php index 734350da8..002aafa76 100755 --- a/tests/Behat/Context/Setup/PageContext.php +++ b/tests/Behat/Context/Setup/PageContext.php @@ -61,7 +61,7 @@ public function __construct( ProductRepositoryInterface $productRepository, SectionRepositoryInterface $sectionRepository, MediaUploaderInterface $mediaUploader, - ) { + ) { $this->sharedStorage = $sharedStorage; $this->randomStringGenerator = $randomStringGenerator; $this->pageFactory = $pageFactory; @@ -225,7 +225,7 @@ private function createPage( ?string $name = null, ?string $content = null, ChannelInterface $channel = null, - ): PageInterface { + ): PageInterface { /** @var PageInterface $page */ $page = $this->pageFactory->createNew(); diff --git a/tests/Behat/Context/Setup/SectionContext.php b/tests/Behat/Context/Setup/SectionContext.php index 048938f59..6b824993a 100755 --- a/tests/Behat/Context/Setup/SectionContext.php +++ b/tests/Behat/Context/Setup/SectionContext.php @@ -34,7 +34,7 @@ public function __construct( RandomStringGeneratorInterface $randomStringGenerator, FactoryInterface $sectionFactory, SectionRepositoryInterface $sectionRepository, - ) { + ) { $this->sharedStorage = $sharedStorage; $this->randomStringGenerator = $randomStringGenerator; $this->sectionFactory = $sectionFactory; diff --git a/tests/Behat/Context/Ui/Admin/BlockContext.php b/tests/Behat/Context/Ui/Admin/BlockContext.php index cd7da0926..6e723a55f 100755 --- a/tests/Behat/Context/Ui/Admin/BlockContext.php +++ b/tests/Behat/Context/Ui/Admin/BlockContext.php @@ -58,7 +58,7 @@ public function __construct( UpdatePageInterface $updatePage, RandomStringGeneratorInterface $randomStringGenerator, BlockRepositoryInterface $blockRepository, - ) { + ) { $this->sharedStorage = $sharedStorage; $this->currentPageResolver = $currentPageResolver; $this->notificationChecker = $notificationChecker; diff --git a/tests/Behat/Context/Ui/Admin/FrequentlyAskedQuestionContext.php b/tests/Behat/Context/Ui/Admin/FrequentlyAskedQuestionContext.php index cdd4a13e5..b12e17efc 100755 --- a/tests/Behat/Context/Ui/Admin/FrequentlyAskedQuestionContext.php +++ b/tests/Behat/Context/Ui/Admin/FrequentlyAskedQuestionContext.php @@ -53,7 +53,7 @@ public function __construct( CreatePageInterface $createPage, UpdatePageInterface $updatePage, RandomStringGeneratorInterface $randomStringGenerator, - ) { + ) { $this->sharedStorage = $sharedStorage; $this->currentPageResolver = $currentPageResolver; $this->notificationChecker = $notificationChecker; diff --git a/tests/Behat/Context/Ui/Admin/MediaContext.php b/tests/Behat/Context/Ui/Admin/MediaContext.php index 77b969dd6..41819fd30 100755 --- a/tests/Behat/Context/Ui/Admin/MediaContext.php +++ b/tests/Behat/Context/Ui/Admin/MediaContext.php @@ -58,7 +58,7 @@ public function __construct( UpdatePageInterface $updatePage, RandomStringGeneratorInterface $randomStringGenerator, MediaRepositoryInterface $mediaRepository, - ) { + ) { $this->sharedStorage = $sharedStorage; $this->currentPageResolver = $currentPageResolver; $this->notificationChecker = $notificationChecker; diff --git a/tests/Behat/Context/Ui/Admin/PageContext.php b/tests/Behat/Context/Ui/Admin/PageContext.php index 24b96d937..11b808a75 100755 --- a/tests/Behat/Context/Ui/Admin/PageContext.php +++ b/tests/Behat/Context/Ui/Admin/PageContext.php @@ -58,7 +58,7 @@ public function __construct( UpdatePageInterface $updatePage, RandomStringGeneratorInterface $randomStringGenerator, PageRepositoryInterface $pageRepository, - ) { + ) { $this->sharedStorage = $sharedStorage; $this->currentPageResolver = $currentPageResolver; $this->notificationChecker = $notificationChecker; diff --git a/tests/Behat/Context/Ui/Admin/SectionContext.php b/tests/Behat/Context/Ui/Admin/SectionContext.php index 05162b91f..43518855a 100755 --- a/tests/Behat/Context/Ui/Admin/SectionContext.php +++ b/tests/Behat/Context/Ui/Admin/SectionContext.php @@ -53,7 +53,7 @@ public function __construct( CreatePageInterface $createPage, UpdatePageInterface $updatePage, RandomStringGeneratorInterface $randomStringGenerator, - ) { + ) { $this->sharedStorage = $sharedStorage; $this->currentPageResolver = $currentPageResolver; $this->notificationChecker = $notificationChecker; diff --git a/tests/Behat/Context/Ui/Shop/PageContext.php b/tests/Behat/Context/Ui/Shop/PageContext.php index 53b5ffc0e..f0b5cc837 100755 --- a/tests/Behat/Context/Ui/Shop/PageContext.php +++ b/tests/Behat/Context/Ui/Shop/PageContext.php @@ -31,7 +31,7 @@ public function __construct( ShowPageInterface $showPage, IndexPageInterface $indexPage, SharedStorageInterface $sharedStorage, - ) { + ) { $this->showPage = $showPage; $this->indexPage = $indexPage; $this->sharedStorage = $sharedStorage; diff --git a/tests/Behat/Service/FormHelper.php b/tests/Behat/Service/FormHelper.php index 6f33c70d0..123e5d009 100644 --- a/tests/Behat/Service/FormHelper.php +++ b/tests/Behat/Service/FormHelper.php @@ -19,7 +19,7 @@ public static function fillHiddenInput( Session $session, string $id, $value, - ): void { + ): void { try { $session->executeScript( sprintf( diff --git a/tests/Behat/Service/WysiwygHelper.php b/tests/Behat/Service/WysiwygHelper.php index 372f02cbd..d6e63d788 100644 --- a/tests/Behat/Service/WysiwygHelper.php +++ b/tests/Behat/Service/WysiwygHelper.php @@ -22,7 +22,7 @@ public static function fillContent( DocumentElement $document, string $content, int $iframeNumber = 1, - ): void { + ): void { Assert::isInstanceOf($session->getDriver(), ChromeDriver::class); $session->wait(3000); diff --git a/tests/Functional/FunctionalTestCase.php b/tests/Functional/FunctionalTestCase.php index a1d25b996..8580d5bb7 100644 --- a/tests/Functional/FunctionalTestCase.php +++ b/tests/Functional/FunctionalTestCase.php @@ -20,7 +20,7 @@ abstract class FunctionalTestCase extends BaseJsonApiTestCase public function __construct( ?string $name = null, array $data = [], - string $dataName = '' + string $dataName = '', ) { parent::__construct($name, $data, $dataName); From 8736a52725f306fff98646155e10992481e8efd7 Mon Sep 17 00:00:00 2001 From: Francis Hilaire Date: Mon, 13 May 2024 22:30:18 +0200 Subject: [PATCH 25/33] Support for PantherDriver --- behat.yml.dist | 2 ++ tests/Behat/Page/Admin/Block/CreatePage.php | 4 ++-- tests/Behat/Page/Admin/Media/CreatePage.php | 4 ++-- tests/Behat/Page/Admin/Page/CreatePage.php | 6 +++--- tests/Behat/Service/WysiwygHelper.php | 4 ++-- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/behat.yml.dist b/behat.yml.dist index 822beee02..6a188c551 100755 --- a/behat.yml.dist +++ b/behat.yml.dist @@ -36,6 +36,8 @@ default: validate_certificate: false panther: panther: + options: + webServerDir: "%paths.base%/tests/Application/public" manager_options: connection_timeout_in_ms: 5000 request_timeout_in_ms: 120000 diff --git a/tests/Behat/Page/Admin/Block/CreatePage.php b/tests/Behat/Page/Admin/Block/CreatePage.php index e655c3da9..6fc59e55f 100755 --- a/tests/Behat/Page/Admin/Block/CreatePage.php +++ b/tests/Behat/Page/Admin/Block/CreatePage.php @@ -10,7 +10,7 @@ namespace Tests\BitBag\SyliusCmsPlugin\Behat\Page\Admin\Block; -use DMore\ChromeDriver\ChromeDriver; +use Behat\Mink\Driver\PantherDriver; use Sylius\Behat\Page\Admin\Crud\CreatePage as BaseCreatePage; use Tests\BitBag\SyliusCmsPlugin\Behat\Behaviour\ContainsErrorTrait; use Webmozart\Assert\Assert; @@ -51,7 +51,7 @@ public function disable(): void public function associateSections(array $sectionsNames): void { - Assert::isInstanceOf($this->getDriver(), ChromeDriver::class); + Assert::isInstanceOf($this->getDriver(), PantherDriver::class); $dropdown = $this->getElement('association_dropdown_section'); $dropdown->click(); diff --git a/tests/Behat/Page/Admin/Media/CreatePage.php b/tests/Behat/Page/Admin/Media/CreatePage.php index 3876c96de..c7385c2b1 100755 --- a/tests/Behat/Page/Admin/Media/CreatePage.php +++ b/tests/Behat/Page/Admin/Media/CreatePage.php @@ -10,7 +10,7 @@ namespace Tests\BitBag\SyliusCmsPlugin\Behat\Page\Admin\Media; -use DMore\ChromeDriver\ChromeDriver; +use Behat\Mink\Driver\PantherDriver; use Sylius\Behat\Page\Admin\Crud\CreatePage as BaseCreatePage; use Tests\BitBag\SyliusCmsPlugin\Behat\Behaviour\ContainsErrorTrait; use Webmozart\Assert\Assert; @@ -50,7 +50,7 @@ public function fillContent(string $content): void public function associateSections(array $sectionsNames): void { - Assert::isInstanceOf($this->getDriver(), ChromeDriver::class); + Assert::isInstanceOf($this->getDriver(), PantherDriver::class); $dropdown = $this->getElement('association_dropdown_section'); $dropdown->click(); diff --git a/tests/Behat/Page/Admin/Page/CreatePage.php b/tests/Behat/Page/Admin/Page/CreatePage.php index 537788973..39131ab09 100755 --- a/tests/Behat/Page/Admin/Page/CreatePage.php +++ b/tests/Behat/Page/Admin/Page/CreatePage.php @@ -10,7 +10,7 @@ namespace Tests\BitBag\SyliusCmsPlugin\Behat\Page\Admin\Page; -use DMore\ChromeDriver\ChromeDriver; +use Behat\Mink\Driver\PantherDriver; use Sylius\Behat\Page\Admin\Crud\CreatePage as BaseCreatePage; use Sylius\Behat\Service\SlugGenerationHelper; use Tests\BitBag\SyliusCmsPlugin\Behat\Behaviour\ContainsErrorTrait; @@ -40,7 +40,7 @@ public function fillName(string $name): void { $this->getDocument()->fillField('Name', $name); - if ($this->getDriver() instanceof ChromeDriver) { + if ($this->getDriver() instanceof PantherDriver) { SlugGenerationHelper::waitForSlugGeneration($this->getSession(), $this->getElement('slug')); } } @@ -67,7 +67,7 @@ public function fillContent(string $content): void public function associateSections(array $sectionsNames): void { - Assert::isInstanceOf($this->getDriver(), ChromeDriver::class); + Assert::isInstanceOf($this->getDriver(), PantherDriver::class); $dropdown = $this->getElement('association_dropdown_section'); $dropdown->click(); diff --git a/tests/Behat/Service/WysiwygHelper.php b/tests/Behat/Service/WysiwygHelper.php index d6e63d788..1aa7ca89f 100644 --- a/tests/Behat/Service/WysiwygHelper.php +++ b/tests/Behat/Service/WysiwygHelper.php @@ -12,7 +12,7 @@ use Behat\Mink\Element\DocumentElement; use Behat\Mink\Session; -use DMore\ChromeDriver\ChromeDriver; +use Behat\Mink\Driver\PantherDriver; use Webmozart\Assert\Assert; final class WysiwygHelper @@ -23,7 +23,7 @@ public static function fillContent( string $content, int $iframeNumber = 1, ): void { - Assert::isInstanceOf($session->getDriver(), ChromeDriver::class); + Assert::isInstanceOf($session->getDriver(), PantherDriver::class); $session->wait(3000); $session->switchToIFrame($iframeNumber); From 41131089482255b64527461a7420f5b2dbd2d199 Mon Sep 17 00:00:00 2001 From: Francis Hilaire Date: Mon, 13 May 2024 22:31:22 +0200 Subject: [PATCH 26/33] Bring back Sylius 1.12 support --- .github/workflows/build.yml | 8 ++++++-- composer.json | 2 +- tests/Application/Kernel.php | 10 ++++++++++ tests/Application/config/bundles.php | 1 - ...us_cms_plugin.yml => bitbag_sylius_cms_plugin.yaml} | 0 ...us_cms_plugin.yml => bitbag_sylius_cms_plugin.yaml} | 0 tests/Application/config/sylius/1.13/bundles.php | 7 +++++++ 7 files changed, 24 insertions(+), 4 deletions(-) rename tests/Application/config/packages/{bitbag_sylius_cms_plugin.yml => bitbag_sylius_cms_plugin.yaml} (100%) rename tests/Application/config/routes/{bitbag_sylius_cms_plugin.yml => bitbag_sylius_cms_plugin.yaml} (100%) create mode 100644 tests/Application/config/sylius/1.13/bundles.php diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 663c4ecf7..716d157c0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,12 +21,16 @@ jobs: strategy: fail-fast: false matrix: - php: ["8.1", "8.2", "8.3"] + php: ["8.0", "8.1", "8.2", "8.3"] symfony: ["^5.4", "^6.4"] - sylius: ["~1.13.0"] + sylius: ["~1.12.0", "~1.13.0"] node: ["20.x"] mysql: ["8.0"] + exclude: + - sylius: "~1.13.0" + php: "^8.0" + env: APP_ENV: test DATABASE_URL: "mysql://root:root@127.0.0.1/sylius?serverVersion=${{ matrix.mysql }}" diff --git a/composer.json b/composer.json index 1905ccfd7..93ad98869 100755 --- a/composer.json +++ b/composer.json @@ -9,7 +9,7 @@ "description": "CMS plugin for Sylius applications.", "license": "MIT", "require": { - "sylius/sylius": "~1.13.0", + "sylius/sylius": "~1.12.0 || ~1.13.0", "league/csv": "^9.1", "friendsofsymfony/ckeditor-bundle": "^2.0", "instaclick/php-webdriver": "^1.4", diff --git a/tests/Application/Kernel.php b/tests/Application/Kernel.php index fd5a36f70..769ca698b 100755 --- a/tests/Application/Kernel.php +++ b/tests/Application/Kernel.php @@ -19,6 +19,16 @@ final class Kernel extends BaseKernel private const CONFIG_EXTS = '.{php,xml,yaml,yml}'; + public function getCacheDir(): string + { + return $this->getProjectDir() . '/var/cache/' . $this->environment; + } + + public function getLogDir(): string + { + return $this->getProjectDir() . '/var/log'; + } + public function registerBundles(): iterable { foreach ($this->getConfigurationDirectories() as $confDir) { diff --git a/tests/Application/config/bundles.php b/tests/Application/config/bundles.php index c23aab419..48ddcbe01 100644 --- a/tests/Application/config/bundles.php +++ b/tests/Application/config/bundles.php @@ -8,7 +8,6 @@ Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true], Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true], Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true], - Sylius\Abstraction\StateMachine\SyliusStateMachineAbstractionBundle::class => ['all' => true], Sylius\Calendar\SyliusCalendarBundle::class => ['all' => true], Sylius\Bundle\OrderBundle\SyliusOrderBundle::class => ['all' => true], Sylius\Bundle\MoneyBundle\SyliusMoneyBundle::class => ['all' => true], diff --git a/tests/Application/config/packages/bitbag_sylius_cms_plugin.yml b/tests/Application/config/packages/bitbag_sylius_cms_plugin.yaml similarity index 100% rename from tests/Application/config/packages/bitbag_sylius_cms_plugin.yml rename to tests/Application/config/packages/bitbag_sylius_cms_plugin.yaml diff --git a/tests/Application/config/routes/bitbag_sylius_cms_plugin.yml b/tests/Application/config/routes/bitbag_sylius_cms_plugin.yaml similarity index 100% rename from tests/Application/config/routes/bitbag_sylius_cms_plugin.yml rename to tests/Application/config/routes/bitbag_sylius_cms_plugin.yaml diff --git a/tests/Application/config/sylius/1.13/bundles.php b/tests/Application/config/sylius/1.13/bundles.php new file mode 100644 index 000000000..5d54121b4 --- /dev/null +++ b/tests/Application/config/sylius/1.13/bundles.php @@ -0,0 +1,7 @@ + ['all' => true], +]; From 28175be0f824e543c51b16b2e39801415fcc2834 Mon Sep 17 00:00:00 2001 From: Francis Hilaire Date: Mon, 13 May 2024 22:35:03 +0200 Subject: [PATCH 27/33] Fix ECS --- tests/Behat/Service/WysiwygHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Behat/Service/WysiwygHelper.php b/tests/Behat/Service/WysiwygHelper.php index 1aa7ca89f..e174d90fa 100644 --- a/tests/Behat/Service/WysiwygHelper.php +++ b/tests/Behat/Service/WysiwygHelper.php @@ -10,9 +10,9 @@ namespace Tests\BitBag\SyliusCmsPlugin\Behat\Service; +use Behat\Mink\Driver\PantherDriver; use Behat\Mink\Element\DocumentElement; use Behat\Mink\Session; -use Behat\Mink\Driver\PantherDriver; use Webmozart\Assert\Assert; final class WysiwygHelper From 684887b2281bb266d2b8996323da1805a38afea1 Mon Sep 17 00:00:00 2001 From: Francis Hilaire Date: Mon, 13 May 2024 22:36:34 +0200 Subject: [PATCH 28/33] Avoid testing too old php version --- .github/workflows/build.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 716d157c0..e08514ec0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,16 +21,12 @@ jobs: strategy: fail-fast: false matrix: - php: ["8.0", "8.1", "8.2", "8.3"] + php: ["8.1", "8.2", "8.3"] symfony: ["^5.4", "^6.4"] sylius: ["~1.12.0", "~1.13.0"] node: ["20.x"] mysql: ["8.0"] - exclude: - - sylius: "~1.13.0" - php: "^8.0" - env: APP_ENV: test DATABASE_URL: "mysql://root:root@127.0.0.1/sylius?serverVersion=${{ matrix.mysql }}" From a537e69183bcb5f307c90016f3e8ea5d193afd1f Mon Sep 17 00:00:00 2001 From: Francis Hilaire Date: Tue, 14 May 2024 00:06:09 +0200 Subject: [PATCH 29/33] Fix Behat scenario by using the right pathPrefix --- tests/Application/config/packages/liip_imagine.yaml | 6 ------ tests/Behat/Context/Setup/PageContext.php | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/tests/Application/config/packages/liip_imagine.yaml b/tests/Application/config/packages/liip_imagine.yaml index 4381e52dc..bb2e7ceb9 100644 --- a/tests/Application/config/packages/liip_imagine.yaml +++ b/tests/Application/config/packages/liip_imagine.yaml @@ -1,10 +1,4 @@ liip_imagine: - loaders: - default: - filesystem: - data_root: - - "%sylius_core.public_dir%/media/image" - - "%sylius_core.public_dir%" resolvers: default: web_path: diff --git a/tests/Behat/Context/Setup/PageContext.php b/tests/Behat/Context/Setup/PageContext.php index 002aafa76..3135d48b7 100755 --- a/tests/Behat/Context/Setup/PageContext.php +++ b/tests/Behat/Context/Setup/PageContext.php @@ -265,7 +265,7 @@ private function uploadImage(string $name): MediaInterface $image->setFile($uploadedImage); - $this->mediaUploader->upload($image, '/tests/Application/Resources/images/'); + $this->mediaUploader->upload($image, 'media/image'); return $image; } From 3f61a716e7b697965490a4356eceb778fbbde186 Mon Sep 17 00:00:00 2001 From: Francis Hilaire Date: Tue, 14 May 2024 00:22:04 +0200 Subject: [PATCH 30/33] Remove unecessary ignore --- tests/Application/.gitignore | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/Application/.gitignore b/tests/Application/.gitignore index ae0b710a0..0de8f0401 100644 --- a/tests/Application/.gitignore +++ b/tests/Application/.gitignore @@ -3,9 +3,6 @@ /public/css /public/js /public/media/* -!/public/media/image/ -/public/media/image/* -!/public/media/image/.gitignore /node_modules /yarn-error.log From c138c2857a4f3f63b5686d9b16065f1b5a662994 Mon Sep 17 00:00:00 2001 From: Francis Hilaire Date: Tue, 14 May 2024 00:22:40 +0200 Subject: [PATCH 31/33] Fix Behat, use ImageProvider instead of a raw uploader --- tests/Behat/Context/Setup/PageContext.php | 12 ++++++------ tests/Behat/Resources/services/contexts/setup.yml | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/Behat/Context/Setup/PageContext.php b/tests/Behat/Context/Setup/PageContext.php index 3135d48b7..044be81eb 100755 --- a/tests/Behat/Context/Setup/PageContext.php +++ b/tests/Behat/Context/Setup/PageContext.php @@ -14,9 +14,9 @@ use BitBag\SyliusCmsPlugin\Entity\Media; use BitBag\SyliusCmsPlugin\Entity\MediaInterface; use BitBag\SyliusCmsPlugin\Entity\PageInterface; +use BitBag\SyliusCmsPlugin\MediaProvider\ProviderInterface; use BitBag\SyliusCmsPlugin\Repository\PageRepositoryInterface; use BitBag\SyliusCmsPlugin\Repository\SectionRepositoryInterface; -use BitBag\SyliusCmsPlugin\Uploader\MediaUploaderInterface; use Doctrine\ORM\EntityManagerInterface; use Sylius\Behat\Service\SharedStorageInterface; use Sylius\Component\Core\Formatter\StringInflector; @@ -49,8 +49,8 @@ final class PageContext implements Context /** @var SectionRepositoryInterface */ private $sectionRepository; - /** @var MediaUploaderInterface */ - private $mediaUploader; + /** @var ProviderInterface */ + private $imageProvider; public function __construct( SharedStorageInterface $sharedStorage, @@ -60,7 +60,7 @@ public function __construct( EntityManagerInterface $entityManager, ProductRepositoryInterface $productRepository, SectionRepositoryInterface $sectionRepository, - MediaUploaderInterface $mediaUploader, + ProviderInterface $imageProvider, ) { $this->sharedStorage = $sharedStorage; $this->randomStringGenerator = $randomStringGenerator; @@ -69,7 +69,7 @@ public function __construct( $this->entityManager = $entityManager; $this->productRepository = $productRepository; $this->sectionRepository = $sectionRepository; - $this->mediaUploader = $mediaUploader; + $this->imageProvider = $imageProvider; } /** @@ -265,7 +265,7 @@ private function uploadImage(string $name): MediaInterface $image->setFile($uploadedImage); - $this->mediaUploader->upload($image, 'media/image'); + $this->imageProvider->upload($image); return $image; } diff --git a/tests/Behat/Resources/services/contexts/setup.yml b/tests/Behat/Resources/services/contexts/setup.yml index 94a500eed..f4a0a5afa 100755 --- a/tests/Behat/Resources/services/contexts/setup.yml +++ b/tests/Behat/Resources/services/contexts/setup.yml @@ -19,7 +19,7 @@ services: - "@doctrine.orm.entity_manager" - "@sylius.repository.product" - "@bitbag_sylius_cms_plugin.repository.section" - - "@bitbag_sylius_cms_plugin.media_uploader" + - "@bitbag_sylius_cms_plugin.media_provider.image" bitbag_sylius_cms_plugin.behat.context.setup.frequently_asked_question: class: Tests\BitBag\SyliusCmsPlugin\Behat\Context\Setup\FrequentlyAskedQuestionContext From f3a9b140abf9989dfb7cf06112fb2fde203ea80b Mon Sep 17 00:00:00 2001 From: Francis Hilaire Date: Tue, 14 May 2024 12:06:51 +0200 Subject: [PATCH 32/33] Remove unecessary Chrome boot --- .github/workflows/build.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e08514ec0..cd16ce8c6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -69,10 +69,6 @@ jobs: name: Install certificates run: symfony server:ca:install - - - 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='*' http://127.0.0.1 > /dev/null 2>&1 & - - name: Run webserver run: (cd tests/Application && symfony server:start --port=8080 --dir=public --daemon) From 065a6d5c5eba318fee85dfd562dd4fe75800c475 Mon Sep 17 00:00:00 2001 From: Francis Hilaire Date: Tue, 14 May 2024 13:27:00 +0200 Subject: [PATCH 33/33] The env is loaded by dotenv thanks to the bootstrap file --- phpunit.xml.dist | 2 -- 1 file changed, 2 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index aa1bc1a44..ed1a450bd 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -15,7 +15,5 @@ - -