Skip to content

Commit

Permalink
OP-289: Bump min required patches, fix version selection in builds, f…
Browse files Browse the repository at this point in the history
…ix 1.12 compatibility
  • Loading branch information
hmfilar committed Sep 17, 2024
1 parent eec3b65 commit 67b2053
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
matrix:
php: [ "8.1", "8.2", "8.3" ]
symfony: [ "^5.4", "^6.4" ]
sylius: [ "^1.12", "^1.13" ]
sylius: [ "~1.12.17", "~1.13.2" ]
node: [ "18.x", "20.x" ]
mysql: [ "8.0" ]

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coding_standard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
matrix:
php: [ "8.1", "8.2", "8.3" ]
symfony: [ "^5.4", "^6.4" ]
sylius: [ "^1.12", "^1.13" ]
sylius: [ "~1.12.17", "~1.13.2" ]
node: [ "18.x", "20.x" ]

steps:
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"license": "MIT",
"require": {
"php": "^8.1",
"sylius/sylius": "~1.12.0 || ~1.13.0"
"sylius/sylius": "~1.12.17 || ~1.13.2"
},
"require-dev": {
"ext-json": "*",
Expand Down
12 changes: 6 additions & 6 deletions features/having_bundled_product_in_store.feature
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,17 @@ 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
Scenario: Adding unpacked product bundles to cart and overwriting variants with invalid variant with API
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
Expand All @@ -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
6 changes: 2 additions & 4 deletions src/Provider/AddProductBundleItemToCartCommandProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,12 @@ private function overwriteVariant(

private function shouldOverwriteVariant(string $oldVariantCode, string $newVariantCode): bool
{
/** @var ?ProductVariantInterface $oldVariant */
$oldVariant = $this->productVariantRepository->findOneBy(['code' => $oldVariantCode]);
/** @var ?ProductVariantInterface $oldVariant */
$newVariant = $this->productVariantRepository->findOneBy(['code' => $newVariantCode]);

return
null !== $oldVariant &&
null !== $newVariant &&
$oldVariant instanceof ProductVariantInterface &&
$newVariant instanceof ProductVariantInterface &&
$oldVariant->getProduct() === $newVariant->getProduct();
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% if product.isConfigurable() and product.getVariantSelectionMethod() == 'match' and not product.enabledVariants.empty() %}
{% include '@SyliusShop/Product/Show/_variantsPricing.html.twig' with {'pricing': sylius_product_variants_map(product, {'channel': sylius.channel}), 'variants': product.enabledVariants} %}
{% include '@SyliusShop/Product/Show/_variantsPricing.html.twig' with {'pricing': sylius_product_variant_prices(product, sylius.channel), 'variants': product.enabledVariants} %}
{% endif %}

{% include '@BitBagSyliusProductBundlePlugin/Shop/Product/Show/_inventory.html.twig' %}
Expand Down
12 changes: 10 additions & 2 deletions tests/Behat/Context/Api/ProductBundleContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -30,6 +31,7 @@ public function __construct(
private readonly ApiClientInterface $client,
private readonly RequestFactoryInterface $requestFactory,
private readonly ResponseCheckerInterface $responseChecker,
private readonly ProductVariantRepositoryInterface $productVariantRepository,
) {
}

Expand Down Expand Up @@ -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'];
Expand All @@ -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'];
Expand Down
1 change: 1 addition & 0 deletions tests/Behat/Resources/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,4 @@ services:
- '@sylius.behat.api_platform_client.shop'
- '@sylius.behat.request_factory'
- '@Sylius\Behat\Client\ResponseCheckerInterface'
- '@sylius.repository.product_variant'
2 changes: 0 additions & 2 deletions tests/Behat/Resources/suites.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 67b2053

Please sign in to comment.