From bd8d8ad4432f9e68ce9df6250812c3b3d4f35570 Mon Sep 17 00:00:00 2001 From: Lorenzo Ruozzi Date: Mon, 27 May 2024 09:55:32 +0200 Subject: [PATCH] Upgrade for Sylius 1.13 --- .github/workflows/build.yml | 23 ++++------ behat.yml.dist | 45 +++++++++++-------- composer.json | 15 ++++--- phpstan.neon | 5 ++- symfony.lock | 21 +++++++++ tests/Application/config/bundles.php | 7 ++- .../AttributeOptions/ImporterTest.php | 2 +- tests/Integration/Product/ImporterTest.php | 19 ++++---- tests/Integration/Product/ReconcilerTest.php | 2 +- .../ProductAssociations/ImporterTest.php | 2 +- .../Integration/ProductModel/ImporterTest.php | 2 +- 11 files changed, 89 insertions(+), 54 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c2aa5925..6551d7ee 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,17 +21,12 @@ jobs: strategy: fail-fast: false matrix: - php: ["8.0", "8.1", "8.2"] + php: ["8.1", "8.2", "8.3"] symfony: ["^5.4", "^6.4"] - sylius: ["^1.12.13"] + sylius: ["1.12.16", "1.13.1"] node: ["18.x"] mysql: ["8.0"] - exclude: - - - php: "8.0" - symfony: "^6.4" - env: APP_ENV: test DATABASE_URL: "mysql://root:root@127.0.0.1/sylius?serverVersion=${{ matrix.mysql }}" @@ -51,7 +46,7 @@ jobs: - name: Setup Node - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: "${{ matrix.node }}" @@ -82,6 +77,10 @@ jobs: name: Run webserver run: (cd tests/Application && symfony server:start --port=8080 --dir=public --daemon) + - + name: Validate composer.json + run: composer validate --ansi --strict + - name: Get Composer cache directory id: composer-cache @@ -89,7 +88,7 @@ jobs: - name: Cache Composer - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json **/composer.lock') }} @@ -126,7 +125,7 @@ jobs: - name: Cache Yarn - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ${{ steps.yarn-cache.outputs.dir }} key: ${{ runner.os }}-node-${{ matrix.node }}-yarn-${{ hashFiles('**/package.json **/yarn.lock') }} @@ -158,10 +157,6 @@ jobs: name: Load fixtures in test application run: (cd tests/Application && bin/console sylius:fixtures:load -n) - - - name: Validate composer.json - run: composer validate --ansi --strict - - name: Validate database schema run: (cd tests/Application && bin/console doctrine:schema:validate) diff --git a/behat.yml.dist b/behat.yml.dist index 92d3b071..ca0f3bc3 100644 --- a/behat.yml.dist +++ b/behat.yml.dist @@ -3,11 +3,18 @@ imports: - tests/Behat/Resources/suites.yml default: + formatters: + pretty: + verbose: true + paths: false + snippets: false + gherkin: filters: tags: "~@todo" extensions: DMore\ChromeExtension\Behat\ServiceContainer\ChromeExtension: ~ + Robertfausk\Behat\PantherExtension: ~ FriendsOfBehat\MinkDebugExtension: directory: etc/build @@ -18,32 +25,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 - 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: @@ -56,3 +61,5 @@ default: FriendsOfBehat\SuiteSettingsExtension: paths: - "features" + + SyliusLabs\SuiteTagsExtension: ~ diff --git a/composer.json b/composer.json index 0276f8ff..8dd15389 100644 --- a/composer.json +++ b/composer.json @@ -8,14 +8,12 @@ ], "license": "MIT", "require": { - "php": "^8.0", + "php": "^8.1", "akeneo/api-php-client": "^11", "cocur/slugify": "^4.0", - "guzzlehttp/guzzle": "^6.5", + "guzzlehttp/guzzle": "^6.5 || ^7.6", "http-interop/http-factory-guzzle": "^1.0", - "php-http/guzzle6-adapter": "^2.0", - "sylius/mailer-bundle": "^1.8 || ^2.0", - "sylius/sylius": "^1.12.11", + "sylius/sylius": "^1.12.11 || ^1.13", "symfony/deprecation-contracts": "^2.2", "symfony/lock": "^5.4 || ^6.0", "symfony/webpack-encore-bundle": "^1.15" @@ -23,7 +21,8 @@ "require-dev": { "ext-json": "*", "behat/behat": "^3.14", - "behat/mink-selenium2-driver": "1.6", + "behat/mink-selenium2-driver": "^1.6", + "dbrekelmans/bdi": "^1.1", "dmore/behat-chrome-extension": "^1.4", "dmore/chrome-mink-driver": "^2.9", "friends-of-behat/mink": "^1.11", @@ -43,9 +42,11 @@ "phpstan/phpstan-doctrine": "^1.3", "phpstan/phpstan-strict-rules": "^1.5", "phpstan/phpstan-webmozart-assert": "^1.2", - "phpunit/phpunit": "^9.6", + "phpunit/phpunit": "^9.6 || ^10.5", "polishsymfonycommunity/symfony-mocker-container": "^1.0", + "robertfausk/behat-panther-extension": "^1.1", "sylius-labs/coding-standard": "^4.3", + "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", diff --git a/phpstan.neon b/phpstan.neon index e9be45f6..a8ae9721 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,7 +1,6 @@ parameters: level: max reportUnmatchedIgnoredErrors: false - checkMissingIterableValueType: false paths: - src - tests/Behat @@ -15,6 +14,10 @@ parameters: - 'tests/Application/src/**.php' ignoreErrors: + - + identifier: missingType.generics # Temp + - + identifier: missingType.iterableValue - '/Parameter #1 \$configuration of method Symfony\\Component\\DependencyInjection\\Extension\\Extension::processConfiguration\(\) expects Symfony\\Component\\Config\\Definition\\ConfigurationInterface, Symfony\\Component\\Config\\Definition\\ConfigurationInterface\|null given\./' - '/Method Symfony\\Contracts\\EventDispatcher\\EventDispatcherInterface::dispatch\(\) invoked with 2 parameters, 1 required\./' - '/Parameter \#1 \$event of method Symfony\\Contracts\\EventDispatcher\\EventDispatcherInterface::dispatch\(\) expects object, string given\./' diff --git a/symfony.lock b/symfony.lock index 7725201a..1647b290 100644 --- a/symfony.lock +++ b/symfony.lock @@ -348,6 +348,15 @@ "config/packages/monolog.yaml" ] }, + "symfony/panther": { + "version": "2.1", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "main", + "version": "1.0", + "ref": "673836afb0eac2b0ec36c44f2ff0379e5a4b2177" + } + }, "symfony/routing": { "version": "6.4", "recipe": { @@ -444,6 +453,18 @@ "webpack.config.js" ] }, + "symfony/workflow": { + "version": "6.4", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "main", + "version": "3.3", + "ref": "3b2f8ca32a07fcb00f899649053943fa3d8bbfb6" + }, + "files": [ + "config/packages/workflow.yaml" + ] + }, "theofidry/alice-data-fixtures": { "version": "1.7", "recipe": { diff --git a/tests/Application/config/bundles.php b/tests/Application/config/bundles.php index e434d9e8..3ecbc948 100644 --- a/tests/Application/config/bundles.php +++ b/tests/Application/config/bundles.php @@ -1,6 +1,6 @@ ['all' => true], Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true], Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true], @@ -61,3 +61,8 @@ Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true], League\FlysystemBundle\FlysystemBundle::class => ['all' => true], ]; +if (class_exists(Sylius\Abstraction\StateMachine\SyliusStateMachineAbstractionBundle::class)) { + $bundles[Sylius\Abstraction\StateMachine\SyliusStateMachineAbstractionBundle::class] = ['all' => true]; +} + +return $bundles; diff --git a/tests/Integration/AttributeOptions/ImporterTest.php b/tests/Integration/AttributeOptions/ImporterTest.php index 44a014b5..1d485e00 100644 --- a/tests/Integration/AttributeOptions/ImporterTest.php +++ b/tests/Integration/AttributeOptions/ImporterTest.php @@ -97,7 +97,7 @@ protected function setUp(): void 'it_IT' => 'Grande', ])); - $ORMResourceFixturePath = DataFixture::path . '/ORM/resources/Importer/AttributeOptions/' . $this->getName() . '.yaml'; + $ORMResourceFixturePath = DataFixture::path . '/ORM/resources/Importer/AttributeOptions/' . $this->name() . '.yaml'; if (file_exists($ORMResourceFixturePath)) { $fixtureLoader->load( [$ORMResourceFixturePath], diff --git a/tests/Integration/Product/ImporterTest.php b/tests/Integration/Product/ImporterTest.php index bc754e48..2c14727d 100644 --- a/tests/Integration/Product/ImporterTest.php +++ b/tests/Integration/Product/ImporterTest.php @@ -143,7 +143,7 @@ protected function setUp(): void ]); InMemoryProductApi::addResource($this->startWarsTShirtMAkeneoProduct); - $ORMResourceFixturePath = DataFixture::path . '/ORM/resources/Importer/Product/' . $this->getName() . '.yaml'; + $ORMResourceFixturePath = DataFixture::path . '/ORM/resources/Importer/Product/' . $this->name() . '.yaml'; if (file_exists($ORMResourceFixturePath)) { $this->fixtureLoader->load( [$ORMResourceFixturePath], @@ -420,13 +420,16 @@ public function it_sets_all_channels_to_imported_products(): void */ public function it_imports_all_product_images_when_importing_variants_of_configurable_product(): void { - $this->startWarsTShirtMAkeneoProduct->values = [ - 'image' => [[ - 'locale' => null, - 'scope' => null, - 'data' => 'star_wars_m.jpeg', - ]], - ]; + $this->startWarsTShirtMAkeneoProduct->values = array_merge_recursive( + $this->startWarsTShirtMAkeneoProduct->values, + [ + 'image' => [[ + 'locale' => null, + 'scope' => null, + 'data' => 'star_wars_m.jpeg', + ]], + ], + ); $startWarsTShirtLAkeneoProduct = Product::create('STAR_WARS_TSHIRT_L', [ 'family' => $this->tShirtFamily->code, 'parent' => $this->starWarsTShirtProductModel->code, diff --git a/tests/Integration/Product/ReconcilerTest.php b/tests/Integration/Product/ReconcilerTest.php index 30705faf..b5a59a6f 100644 --- a/tests/Integration/Product/ReconcilerTest.php +++ b/tests/Integration/Product/ReconcilerTest.php @@ -25,7 +25,7 @@ protected function setUp(): void $this->productVariantRepository = self::getContainer()->get('sylius.repository.product_variant'); $fixtureLoader = self::getContainer()->get('fidry_alice_data_fixtures.loader.doctrine'); - $ORMResourceFixturePath = DataFixture::path . '/ORM/resources/Reconciler/Product/' . $this->getName() . '.yaml'; + $ORMResourceFixturePath = DataFixture::path . '/ORM/resources/Reconciler/Product/' . $this->name() . '.yaml'; if (file_exists($ORMResourceFixturePath)) { $fixtureLoader->load( [$ORMResourceFixturePath], diff --git a/tests/Integration/ProductAssociations/ImporterTest.php b/tests/Integration/ProductAssociations/ImporterTest.php index 7bc71af5..dcda55dc 100644 --- a/tests/Integration/ProductAssociations/ImporterTest.php +++ b/tests/Integration/ProductAssociations/ImporterTest.php @@ -54,7 +54,7 @@ protected function setUp(): void ], ])); - $ORMResourceFixturePath = DataFixture::path . '/ORM/resources/Importer/ProductAssociations/' . $this->getName() . '.yaml'; + $ORMResourceFixturePath = DataFixture::path . '/ORM/resources/Importer/ProductAssociations/' . $this->name() . '.yaml'; if (file_exists($ORMResourceFixturePath)) { $this->fixtureLoader->load( [$ORMResourceFixturePath], diff --git a/tests/Integration/ProductModel/ImporterTest.php b/tests/Integration/ProductModel/ImporterTest.php index 8c8ea534..ff020a8e 100644 --- a/tests/Integration/ProductModel/ImporterTest.php +++ b/tests/Integration/ProductModel/ImporterTest.php @@ -115,7 +115,7 @@ protected function setUp(): void ]); InMemoryProductApi::addResource($startWarsTShirtMAkeneoProduct); - $ORMResourceFixturePath = DataFixture::path . '/ORM/resources/Importer/ProductModel/' . $this->getName() . '.yaml'; + $ORMResourceFixturePath = DataFixture::path . '/ORM/resources/Importer/ProductModel/' . $this->name() . '.yaml'; if (file_exists($ORMResourceFixturePath)) { $fixtureLoader->load( [$ORMResourceFixturePath],