Skip to content

Commit

Permalink
Merge pull request #1990 from dpfaffenbauer/features/variant
Browse files Browse the repository at this point in the history
[Variants] introduce Variant Bundle
  • Loading branch information
dpfaffenbauer authored May 5, 2022
2 parents 658f353 + 0df56fa commit 205d02a
Show file tree
Hide file tree
Showing 160 changed files with 5,515 additions and 196 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/behat_ui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,11 @@ jobs:
name: "Behat logs (non-JS, PHP ${{ matrix.php }}, Symfony ${{ matrix.pimcore }})"
path: etc/build/
if-no-files-found: ignore

- name: Upload Pimcore logs
uses: actions/upload-artifact@v2
if: failure()
with:
name: "Pimcore logs (non-JS, PHP ${{ matrix.php }}, Symfony ${{ matrix.pimcore }})"
path: var/log/
if-no-files-found: ignore
2 changes: 2 additions & 0 deletions bin/subtree-release
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ split 'src/CoreShop/Component/Tracking' tracking
split 'src/CoreShop/Component/User' user
split 'src/CoreShop/Component/PayumPayment' payum-payment
split 'src/CoreShop/Component/ProductQuantityPriceRules' product-quantity-price-rules
split 'src/CoreShop/Component/Variant' variant

split 'src/CoreShop/Bundle/AddressBundle' address-bundle
split 'src/CoreShop/Bundle/ConfigurationBundle' configuration-bundle
Expand Down Expand Up @@ -71,3 +72,4 @@ split 'src/CoreShop/Bundle/MenuBundle' menu-bundle
split 'src/CoreShop/Bundle/PayumPaymentBundle' payum-payment-bundle
split 'src/CoreShop/Bundle/UserBundle' user-bundle
split 'src/CoreShop/Bundle/OptimisticEntityLockBundle' optimistic-entity-lock-bundle
split 'src/CoreShop/Bundle/VariantBundle' variant-bundle
4 changes: 4 additions & 0 deletions bin/subtree-split
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ remote tracking git@github.com:CoreShop/Tracking.git
remote product-quantity-price-rules git@github.com:CoreShop/ProductQuantityPriceRules.git
remote user git@github.com:CoreShop/User.git
remote payum-payment git@github.com:CoreShop/PayumPayment.git
remote variant git@github.com:CoreShop/Variant.git

remote address-bundle git@github.com:CoreShop/AddressBundle.git
remote configuration-bundle git@github.com:CoreShop/ConfigurationBundle.git
Expand Down Expand Up @@ -105,6 +106,7 @@ remote menu-bundle git@github.com:CoreShop/MenuBundle.git
remote payum-payment-bundle git@github.com:CoreShop/PayumPaymentBundle.git
remote user-bundle git@github.com:CoreShop/UserBundle.git
remote optimistic-entity-lock-bundle git@github.com:CoreShop/OptimisticEntityLockBundle.git
remote variant-bundle git@github.com:CoreShop/VariantBundle.git

split 'src/CoreShop/Component/Resource' resource
split 'src/CoreShop/Component/Registry' registry
Expand Down Expand Up @@ -132,6 +134,7 @@ split 'src/CoreShop/Component/Tracking' tracking
split 'src/CoreShop/Component/ProductQuantityPriceRules' product-quantity-price-rules
split 'src/CoreShop/Component/User' user
split 'src/CoreShop/Component/PayumPayment' payum-payment
split 'src/CoreShop/Component/Variant' variant

split 'src/CoreShop/Bundle/AddressBundle' address-bundle
split 'src/CoreShop/Bundle/ConfigurationBundle' configuration-bundle
Expand Down Expand Up @@ -165,3 +168,4 @@ split 'src/CoreShop/Bundle/MenuBundle' menu-bundle
split 'src/CoreShop/Bundle/UserBundle' user-bundle
split 'src/CoreShop/Bundle/PayumPaymentBundle' payum-payment-bundle
split 'src/CoreShop/Bundle/OptimisticEntityLockBundle' optimistic-entity-lock-bundle
split 'src/CoreShop/Bundle/VariantBundle' variant-bundle
2 changes: 2 additions & 0 deletions config/packages/test/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,7 @@ framework:

monolog:
handlers:
main:
level: error
console:
channels: ['!event', '!doctrine', '!console', '!cache']
39 changes: 39 additions & 0 deletions features/domain/product/variant/adding_attributes.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
@domain @product @variant
Feature: Adding a Attributes

Background:
Given the site operates on a store in "Austria"

Scenario: Create a Color Attribute Group
Given the site has a attribute group "Color"
And the site has a color attribute "red" with hex code "#FF0000" in attribute group
And the site has a color attribute "blue" with hex code "#0000FF" in attribute group
And the site has a color attribute "green" with hex code "#00FF00" in attribute group
Then the attribute group "Color" should have 3 attributes

Scenario: Create a Value Attribute Group
Given the site has a attribute group "Size"
And the site has a value attribute "S" in attribute group
And the site has a value attribute "M" in attribute group
And the site has a value attribute "L" in attribute group
And the site has a value attribute "XL" in attribute group
And the site has a value attribute "XXL" in attribute group
Then the attribute group "Size" should have 5 attributes

Scenario: Create multiple Attribute Group
Given the site has a attribute group "Size"
And the site has a value attribute "S" in attribute group
And the site has a value attribute "M" in attribute group
And the site has a value attribute "L" in attribute group
And the site has a value attribute "XL" in attribute group
And the site has a value attribute "XXL" in attribute group
Then the attribute group "Size" should have 5 attributes
Given the site has a attribute group "Color"
And the site has a color attribute "red" with hex code "#FF0000" in attribute group
And the site has a color attribute "blue" with hex code "#0000FF" in attribute group
And the site has a color attribute "green" with hex code "#00FF00" in attribute group
Then the attribute group "Color" should have 3 attributes
Given the site has a attribute group "Season"
And the site has a value attribute "Winter" in attribute group
And the site has a value attribute "Summer" in attribute group
Then the attribute group "Season" should have 2 attributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
@domain @product @variant
Feature: Adding a new Product with Variants

Background:
Given the site operates on a store in "Austria"
And the site has a attribute group "Color"
And the site has a color attribute "red" with hex code "#FF0000" in attribute group
And the site has a color attribute "blue" with hex code "#0000FF" in attribute group
And the site has a color attribute "green" with hex code "#00FF00" in attribute group

Scenario: Create a new product with 3 variants
Given the site has a product "Shoe" priced at 100
And the product is allowed attribute group "Color"
And the product has a variant "red"
And the variant uses attribute color "red"
And the variant is published
And the product has a variant "blue"
And the variant uses attribute color "blue"
And the variant is published
And the product has a variant "green"
And the variant uses attribute color "green"
And the variant is published
Then the product should have 3 variants
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
@ui @product
Feature: Viewing a product variant details

Background:
Given the site operates on a store in "Austria"
And the store "Austria" is the default store
And the site has a attribute group "Color"
And the site has a color attribute "red" with hex code "#FF0000" in attribute group
And the site has a color attribute "blue" with hex code "#0000FF" in attribute group
And the site has a color attribute "green" with hex code "#00FF00" in attribute group
And the site has a attribute group "Size"
And the site has a value attribute "S" in attribute group
And the site has a value attribute "M" in attribute group
And the site has a value attribute "L" in attribute group
And the site has a value attribute "XL" in attribute group
And the site has a product "T-Shirt"
And the product is active and published and available for store "Austria"
And the product has variants for all values of attribute group "Color" and attribute group "Size"
When I open the variant's detail page
Then I should see the product name "T-Shirt red XL"

Scenario: View product and select other variant
When I click on attribute color "green"
And attribute value "S" is not selected
And attribute value "M" is not selected
And attribute value "L" is not selected
And attribute value "XL" is not selected
When I click on attribute value "S"
Then I should be on the detail page for variant with key "t-shirt-green-s"
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
@ui @product
Feature: Viewing a product variant details

Background:
Given the site operates on a store in "Austria"
And the store "Austria" is the default store
And the site has a attribute group "Color"
And the site has a color attribute "red" with hex code "#FF0000" in attribute group
And the site has a color attribute "blue" with hex code "#0000FF" in attribute group
And the site has a attribute group "Size"
And the site has a value attribute "S" in attribute group
And the site has a value attribute "M" in attribute group
And the site has a product "T-Shirt"
And the product is active and published and available for store "Austria"
And the product is allowed attribute group "Color"
And the product is allowed attribute group "Size"
And the product has a variant "blue-s"
And the variant uses attribute color "blue" and attribute value "s"
And the variant is published
And the product has a variant "red-s"
And the variant uses attribute color "red" and attribute value "s"
And the variant is published
And the product has a variant "red-m"
And the variant uses attribute color "red" and attribute value "m"
And the variant is published
When I open the variant's detail page
Then I should see the product name "red-m"

Scenario: View product and select other variant
When I click on attribute color "blue"
Then attribute value "M" is disabled
Then attribute value "S" is enabled
And attribute color "red" is enabled
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
@ui @product @wip
Feature: Viewing a product variant details

Background:
Given the site operates on a store in "Austria"
And the store "Austria" is the default store
And the site has a attribute group "Color"
And the site has a color attribute "red" with hex code "#FF0000" in attribute group with sorting 1
And the site has a color attribute "blue" with hex code "#0000FF" in attribute group with sorting 2
And the site has a color attribute "green" with hex code "#00FF00" in attribute group with sorting 3
And the site has a attribute group "Size"
And the site has a value attribute "S" in attribute group with sorting 1
And the site has a value attribute "M" in attribute group with sorting 2
And the site has a value attribute "L" in attribute group with sorting 3
And the site has a value attribute "XL" in attribute group with sorting 4
And the site has a attribute group "Season"
And the site has a value attribute "Winter" in attribute group with sorting 1
And the site has a value attribute "Summer" in attribute group with sorting 2
And the site has a product "T-Shirt"
And the product is active and published and available for store "Austria"
And the product has variants for all values of attribute group "Color" and attribute group "Size" and attribute group "Season"
When I open the variant's detail page
Then I should see the product name "T-Shirt red XL Winter"

Scenario: View product and select other variant
When I click on attribute color "green"
And attribute value "S" is not selected
And attribute value "M" is not selected
And attribute value "L" is not selected
And attribute value "XL" is not selected
And attribute value "Summer" is not selected
And attribute value "Winter" is not selected
When I click on attribute value "S"
And attribute value "Summer" is not selected
And attribute value "Winter" is not selected
When I click on attribute value "Winter"
Then I should be on the detail page for variant with key "t-shirt-green-s-winter"
When I click on attribute color "blue"
When I click on attribute value "XL"
When I click on attribute value "Summer"
Then I should be on the detail page for variant with key "t-shirt-blue-xl-summer"
28 changes: 28 additions & 0 deletions features/ui/frontend/product/variant/select_simple_variant.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
@ui @product
Feature: Viewing a product variant details

Background:
Given the site operates on a store in "Austria"
And the store "Austria" is the default store
And the site has a attribute group "Color"
And the site has a color attribute "red" with hex code "#FF0000" in attribute group
And the site has a color attribute "blue" with hex code "#0000FF" in attribute group
And the site has a color attribute "green" with hex code "#00FF00" in attribute group
And the site has a product "T-Shirt"
And the product is active and published and available for store "Austria"
And the product is allowed attribute group "Color"
And the product has a variant "red"
And the variant uses attribute color "red"
And the variant is published
And the product has a variant "blue"
And the variant uses attribute color "blue"
And the variant is published
And the product has a variant "green"
And the variant uses attribute color "green"
And the variant is published
When I open the variant's detail page
Then I should see the product name "green"

Scenario: View product and select other variant
When I click on attribute color "red"
Then I should be on the detail page for variant with key "red"
29 changes: 29 additions & 0 deletions features/ui/frontend/product/variant/view_variant.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
@ui @product
Feature: Viewing a product variant details

Background:
Given the site operates on a store in "Austria"
And the store "Austria" is the default store
And the site has a attribute group "Color"
And the site has a color attribute "red" with hex code "#FF0000" in attribute group
And the site has a color attribute "blue" with hex code "#0000FF" in attribute group
And the site has a color attribute "green" with hex code "#00FF00" in attribute group

Scenario: View product and check if selected
Given the site has a product "T-Shirt"
And the product is active and published and available for store "Austria"
And the product is allowed attribute group "Color"
And the product has a variant "red"
And the variant uses attribute color "red"
And the variant is published
And the product has a variant "blue"
And the variant uses attribute color "blue"
And the variant is published
And the product has a variant "green"
And the variant uses attribute color "green"
And the variant is published
When I open the variant's detail page
Then I should see the product name "green"
And attribute color "green" is selected
And attribute color "red" is not selected

57 changes: 57 additions & 0 deletions src/CoreShop/Behat/Context/Domain/VariantContext.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php
/**
* CoreShop.
*
* This source file is subject to the GNU General Public License version 3 (GPLv3)
* For the full copyright and license information, please view the LICENSE.md and gpl-3.0.txt
* files that are distributed with this source code.
*
* @copyright Copyright (c) CoreShop GmbH (https://www.coreshop.org)
* @license https://www.coreshop.org/license GNU General Public License version 3 (GPLv3)
*/

declare(strict_types=1);

namespace CoreShop\Behat\Context\Domain;

use Behat\Behat\Context\Context;
use CoreShop\Behat\Service\SharedStorageInterface;
use CoreShop\Component\Core\Model\ProductInterface;
use CoreShop\Component\Taxation\Model\TaxRuleGroupInterface;
use CoreShop\Component\Variant\Model\AttributeGroupInterface;
use Pimcore\Model\DataObject\AbstractObject;
use Pimcore\Model\DataObject\Concrete;
use Webmozart\Assert\Assert;

final class VariantContext implements Context
{
public function __construct(protected SharedStorageInterface $sharedStorage)
{
}

/**
* @Then /^the (attribute group "[^"]+") should have (\d+) attributes$/
*/
public function theAttributeGroupShouldHaveXAttributes(AttributeGroupInterface $attributeGroup, int $count): void
{
Assert::eq(
count($attributeGroup->getChildren([AbstractObject::OBJECT_TYPE_OBJECT])),
$count,
sprintf(
'%d attributes have been found in group "%s".',
count($attributeGroup->getChildren([AbstractObject::OBJECT_TYPE_OBJECT])),
$attributeGroup->getRealFullPath()
)
);
}

/**
* @Then /^the (product "[^"]+") should have (\d+) variants$/
* @Then /^the (product) should have (\d+) variants$/
*/
public function theProductShouldHaveVariants(ProductInterface $product, int $count): void
{
Assert::eq(count($product->getChildren([AbstractObject::OBJECT_TYPE_VARIANT], true)), $count);
}

}
Loading

0 comments on commit 205d02a

Please sign in to comment.