Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lruozzi9 committed May 27, 2024
1 parent 0b71b98 commit d082e5d
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 3 deletions.
4 changes: 4 additions & 0 deletions features/importing_product_models.feature
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Feature: Importing product models
@cli
Scenario: Importing product model and its variants
Given there is an attribute "size" on Akeneo of type "pim_catalog_simpleselect"
Given there is an option "M" for attribute "size" on Akeneo
Given there is an option "L" for attribute "size" on Akeneo

And there is a family variant "accessories_size" on Akeneo for the family "accessories"
And the family variant "accessories_size" of family "accessories" has the attribute "size" as axes of first level
Expand All @@ -18,10 +20,12 @@ Feature: Importing product models

And there is a product "BRAIDED_HAT_M" on Akeneo
And the product "BRAIDED_HAT_M" has parent "MODEL_BRAIDED_HAT"
And the product "BRAIDED_HAT_M" has an attribute "size" with data "M"
And the product "BRAIDED_HAT_M" has a price attribute with amount "33.99" and currency "USD"

And there is a product "BRAIDED_HAT_L" on Akeneo
And the product "BRAIDED_HAT_L" has parent "MODEL_BRAIDED_HAT"
And the product "BRAIDED_HAT_L" has an attribute "size" with data "L"
And the product "BRAIDED_HAT_L" has a price attribute with amount "33.00" and currency "USD"

And the store is also available in "it_IT"
Expand Down
8 changes: 8 additions & 0 deletions features/importing_products.feature
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Feature: Importing products
@cli
Scenario: Importing single product model and its variants
Given there is an attribute "size" on Akeneo of type "pim_catalog_simpleselect"
Given there is an option "M" for attribute "size" on Akeneo
Given there is an option "L" for attribute "size" on Akeneo

And there is a family variant "accessories_size" on Akeneo for the family "accessories"
And the family variant "accessories_size" of family "accessories" has the attribute "size" as axes of first level
Expand All @@ -18,10 +20,12 @@ Feature: Importing products

And there is a product "BRAIDED_HAT_M" on Akeneo
And the product "BRAIDED_HAT_M" has parent "MODEL_BRAIDED_HAT"
And the product "BRAIDED_HAT_M" has an attribute "size" with data "M"
And the product "BRAIDED_HAT_M" has a price attribute with amount "33.99" and currency "USD"

And there is a product "BRAIDED_HAT_L" on Akeneo
And the product "BRAIDED_HAT_L" has parent "MODEL_BRAIDED_HAT"
And the product "BRAIDED_HAT_L" has an attribute "size" with data "L"
And the product "BRAIDED_HAT_L" has a price attribute with amount "33.00" and currency "USD"

And the store is also available in "it_IT"
Expand All @@ -34,6 +38,8 @@ Feature: Importing products
@cli
Scenario: Importing products with images should not leave temporary files in temporary files directory
Given there is an attribute "size" on Akeneo of type "pim_catalog_simpleselect"
Given there is an option "M" for attribute "size" on Akeneo
Given there is an option "L" for attribute "size" on Akeneo
Given there is an attribute "attachment" on Akeneo of type "pim_catalog_file"

And there is a family variant "accessories_size" on Akeneo for the family "accessories"
Expand All @@ -43,12 +49,14 @@ Feature: Importing products

And there is a product "BRAIDED_HAT_M" on Akeneo
And the product "BRAIDED_HAT_M" has parent "MODEL_BRAIDED_HAT"
And the product "BRAIDED_HAT_M" has an attribute "size" with data "M"
And the product "BRAIDED_HAT_M" has a price attribute with amount "33.99" and currency "USD"
And the product "BRAIDED_HAT_M" has an attribute "attachment" with data "sample.pdf"
And the product "BRAIDED_HAT_M" has an attribute "image" with data "star_wars_m.jpeg"

And there is a product "BRAIDED_HAT_L" on Akeneo
And the product "BRAIDED_HAT_L" has parent "MODEL_BRAIDED_HAT"
And the product "BRAIDED_HAT_L" has an attribute "size" with data "L"
And the product "BRAIDED_HAT_L" has a price attribute with amount "33.00" and currency "USD"
And the product "BRAIDED_HAT_L" has an attribute "attachment" with data "sample.pdf"
And the product "BRAIDED_HAT_L" has an attribute "image" with data "star_wars_l.jpeg"
Expand Down
6 changes: 3 additions & 3 deletions features/reconciliate_products.feature
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ Feature: Reconcile products
And there is a product "PRODUCT_1_VARIANT_2" updated at "2021-04-19" on Akeneo
And there is a product "PRODUCT_2_VARIANT_2" updated at "2021-04-19" on Akeneo
And the store has a product "product-1-variant-1"
And this product has "product-1-variant-2" variant priced at "$25"
And this product has "product-1-variant-2" variant priced at "$25.00"
And the store has a product "product-2-variant-1"
And this product has "product-2-variant-2" variant priced at "$25"
And this product has "product-2-variant-2" variant priced at "$25.00"
And the store has a product "product-3-variant-1"
And this product has "product-3-variant-2" variant priced at "$25"
And this product has "product-3-variant-2" variant priced at "$25.00"
When I reconcile items
Then the "product-1-variant-1" product should be enabled
And the "product-1-variant-1" product variant should be enabled
Expand Down
28 changes: 28 additions & 0 deletions tests/Behat/Context/Setup/AkeneoAttributeOptionContext.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

declare(strict_types=1);

namespace Tests\Webgriffe\SyliusAkeneoPlugin\Behat\Context\Setup;

use Behat\Behat\Context\Context;
use Tests\Webgriffe\SyliusAkeneoPlugin\InMemory\Client\Api\InMemoryAttributeOptionApi;
use Tests\Webgriffe\SyliusAkeneoPlugin\InMemory\Client\Api\Model\AttributeOption;

final class AkeneoAttributeOptionContext implements Context
{
/**
* @BeforeScenario
*/
public function clear(): void
{
InMemoryAttributeOptionApi::$attributeOptions = [];
}

/**
* @Given there is an option :code for attribute :attributeCode on Akeneo
*/
public function thereIsAnOptionForAttributeOnAkeneo(string $code, string $attributeCode): void
{
InMemoryAttributeOptionApi::addResource(new AttributeOption($code, $attributeCode, 1, []));
}
}
2 changes: 2 additions & 0 deletions tests/Behat/Resources/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

<service id="webgriffe_sylius_akeneo.behat.context.setup.akeneo_attribute" class="Tests\Webgriffe\SyliusAkeneoPlugin\Behat\Context\Setup\AkeneoAttributeContext"/>

<service id="webgriffe_sylius_akeneo.behat.context.setup.akeneo_attribute_option" class="Tests\Webgriffe\SyliusAkeneoPlugin\Behat\Context\Setup\AkeneoAttributeOptionContext"/>

<service id="webgriffe_sylius_akeneo.behat.context.cli.import_command" class="Tests\Webgriffe\SyliusAkeneoPlugin\Behat\Context\Cli\ImportCommandContext">
<argument type="service" id="kernel" />
<argument type="service" id="webgriffe_sylius_akeneo.command.import" />
Expand Down
2 changes: 2 additions & 0 deletions tests/Behat/Resources/suites.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ default:
- webgriffe_sylius_akeneo.behat.context.setup.akeneo_product_model
- webgriffe_sylius_akeneo.behat.context.setup.akeneo_family_variant
- webgriffe_sylius_akeneo.behat.context.setup.akeneo_attribute
- webgriffe_sylius_akeneo.behat.context.setup.akeneo_attribute_option

- webgriffe_sylius_akeneo.behat.context.db.product
- webgriffe_sylius_akeneo.behat.context.cli.import_command
Expand Down Expand Up @@ -51,6 +52,7 @@ default:
- webgriffe_sylius_akeneo.behat.context.setup.akeneo_product_model
- webgriffe_sylius_akeneo.behat.context.setup.akeneo_family_variant
- webgriffe_sylius_akeneo.behat.context.setup.akeneo_attribute
- webgriffe_sylius_akeneo.behat.context.setup.akeneo_attribute_option

- webgriffe_sylius_akeneo.behat.context.db.product
- webgriffe_sylius_akeneo.behat.context.cli.import_command
Expand Down

0 comments on commit d082e5d

Please sign in to comment.