From 0a3130e9f56171fdf9815102901d24fc65883eb6 Mon Sep 17 00:00:00 2001 From: Hubert Filar Date: Mon, 16 Sep 2024 17:03:48 +0200 Subject: [PATCH] [WIP]OP-289: Bump min required patches --- .docker/Dockerfile | 2 +- features/having_bundled_product_in_store.feature | 12 ++++++------ tests/Behat/Context/Api/ProductBundleContext.php | 12 ++++++++++-- tests/Behat/Resources/services.yml | 1 + tests/Behat/Resources/suites.yml | 2 -- 5 files changed, 18 insertions(+), 11 deletions(-) diff --git a/.docker/Dockerfile b/.docker/Dockerfile index 834732c5..f262b23d 100644 --- a/.docker/Dockerfile +++ b/.docker/Dockerfile @@ -1,6 +1,6 @@ FROM ubuntu:20.04 ARG DEBIAN_FRONTEND=noninteractive -ARG PHP_VERSION=8.1 +ARG PHP_VERSION=8.2 ENV LC_ALL=C.UTF-8 # Install basic tools diff --git a/features/having_bundled_product_in_store.feature b/features/having_bundled_product_in_store.feature index 20ea435a..cfe023bb 100644 --- a/features/having_bundled_product_in_store.feature +++ b/features/having_bundled_product_in_store.feature @@ -71,8 +71,8 @@ Feature: Having a product in store which is a bundle of other products When I pick up my cart And I add bundle "Jim Beam&Coke" with quantity 5 to my cart and overwrite "JIM_BEAM" with "JIM_BEAM_1L" Then I should have bundle "Jim Beam&Coke" with quantity 5 in my cart - And I should have product variant "Jim Beam 1L" in bundled items - And I should not have product variant "Jim Beam" in bundled items + And I should have product variant "JIM_BEAM_1L" in bundled items + And I should not have product variant "JIM_BEAM" in bundled items And I should have product "Coca-Cola" in bundled items @api @@ -80,8 +80,8 @@ Feature: Having a product in store which is a bundle of other products When I pick up my cart And I add bundle "Jim Beam&Coke" with quantity 5 to my cart and overwrite "COCA_COLA" with "JIM_BEAM_1L" Then I should have bundle "Jim Beam&Coke" with quantity 5 in my cart - And I should not have product variant "Jim Beam 1L" in bundled items - And I should have product variant "Jim Beam" in bundled items + And I should not have product variant "JIM_BEAM_1L" in bundled items + And I should have product variant "JIM_BEAM" in bundled items And I should have product "Coca-Cola" in bundled items @api @@ -90,6 +90,6 @@ Feature: Having a product in store which is a bundle of other products When I pick up my cart And I add bundle "Jim Beam&Coke" with quantity 5 to my cart and overwrite "JIM_BEAM" with "JIM_BEAM_1L" Then I should have bundle "Jim Beam&Coke" with quantity 5 in my cart - And I should not have product variant "Jim Beam 1L" in bundled items - And I should have product variant "Jim Beam" in bundled items + And I should not have product variant "JIM_BEAM_1L" in bundled items + And I should have product variant "JIM_BEAM" in bundled items And I should have product "Coca-Cola" in bundled items diff --git a/tests/Behat/Context/Api/ProductBundleContext.php b/tests/Behat/Context/Api/ProductBundleContext.php index e08ee862..d408136c 100644 --- a/tests/Behat/Context/Api/ProductBundleContext.php +++ b/tests/Behat/Context/Api/ProductBundleContext.php @@ -20,6 +20,7 @@ use Sylius\Behat\Context\Api\Resources; use Sylius\Behat\Service\SharedStorageInterface; use Sylius\Component\Core\Model\ProductVariantInterface; +use Sylius\Component\Core\Repository\ProductVariantRepositoryInterface; use Symfony\Component\HttpFoundation\Request as HttpRequest; use Webmozart\Assert\Assert; @@ -30,6 +31,7 @@ public function __construct( private readonly ApiClientInterface $client, private readonly RequestFactoryInterface $requestFactory, private readonly ResponseCheckerInterface $responseChecker, + private readonly ProductVariantRepositoryInterface $productVariantRepository, ) { } @@ -116,8 +118,11 @@ public function iShouldHaveProductInBundledItems(ProductInterface $product): voi /** * @When I should have product variant :productVariant in bundled items */ - public function iShouldHaveProductVariantInBundledItems(ProductVariantInterface $productVariant): void + public function iShouldHaveProductVariantInBundledItems(string $productVariant): void { + $productVariant = $this->productVariantRepository->findOneBy(['code' => $productVariant]); + Assert::isInstanceOf($productVariant, ProductVariantInterface::class); + $response = $this->client->show(Resources::ORDERS, $this->sharedStorage->get('cart_token')); $productBundleOrderItems = $this->responseChecker->getValue($response, 'items')[0]['productBundleOrderItems']; @@ -133,8 +138,11 @@ public function iShouldHaveProductVariantInBundledItems(ProductVariantInterface /** * @When I should not have product variant :productVariant in bundled items */ - public function iShouldNotHaveProductVariantInBundledItems(ProductVariantInterface $productVariant): void + public function iShouldNotHaveProductVariantInBundledItems(string $productVariant): void { + $productVariant = $this->productVariantRepository->findOneBy(['code' => $productVariant]); + Assert::isInstanceOf($productVariant, ProductVariantInterface::class); + $response = $this->client->show(Resources::ORDERS, $this->sharedStorage->get('cart_token')); $productBundleOrderItems = $this->responseChecker->getValue($response, 'items')[0]['productBundleOrderItems']; diff --git a/tests/Behat/Resources/services.yml b/tests/Behat/Resources/services.yml index cf7ea5a4..25ae9378 100644 --- a/tests/Behat/Resources/services.yml +++ b/tests/Behat/Resources/services.yml @@ -53,3 +53,4 @@ services: - '@sylius.behat.api_platform_client.shop' - '@sylius.behat.request_factory' - '@Sylius\Behat\Client\ResponseCheckerInterface' + - '@sylius.repository.product_variant' diff --git a/tests/Behat/Resources/suites.yml b/tests/Behat/Resources/suites.yml index 719e3a2f..56af2b95 100644 --- a/tests/Behat/Resources/suites.yml +++ b/tests/Behat/Resources/suites.yml @@ -93,7 +93,6 @@ default: - sylius.behat.context.transform.locale - sylius.behat.context.transform.payment - sylius.behat.context.transform.product - - sylius.behat.context.transform.product_variant - sylius.behat.context.transform.promotion - sylius.behat.context.transform.shared_storage - sylius.behat.context.transform.shipping_method @@ -102,7 +101,6 @@ default: - sylius.behat.context.api.shop.cart - sylius.behat.context.api.shop.checkout - - sylius.behat.context.api.shop.checkout.complete - bitbag_sylius_product_bundle_plugin.behat.context.api.product_bundle - bitbag_sylius_product_bundle_plugin.behat.context.setup.product_bundle