diff --git a/etc/behat/services/contexts/setup.xml b/etc/behat/services/contexts/setup.xml
index 44112a38d2..746f49740f 100644
--- a/etc/behat/services/contexts/setup.xml
+++ b/etc/behat/services/contexts/setup.xml
@@ -106,6 +106,8 @@
+
+
diff --git a/etc/behat/services/contexts/transform.xml b/etc/behat/services/contexts/transform.xml
index 3419b5288b..ee7ed74b9a 100644
--- a/etc/behat/services/contexts/transform.xml
+++ b/etc/behat/services/contexts/transform.xml
@@ -24,6 +24,7 @@
Sylius\Behat\Context\Transform\PaymentContext
Sylius\Behat\Context\Transform\PaymentMethodContext
Sylius\Behat\Context\Transform\ProductContext
+ Sylius\Behat\Context\Transform\ProductOptionContext
Sylius\Behat\Context\Transform\ProductVariantContext
Sylius\Behat\Context\Transform\PromotionContext
Sylius\Behat\Context\Transform\ProvinceContext
diff --git a/etc/behat/services/contexts/ui.xml b/etc/behat/services/contexts/ui.xml
index f2d98859c7..61ce38308f 100644
--- a/etc/behat/services/contexts/ui.xml
+++ b/etc/behat/services/contexts/ui.xml
@@ -20,6 +20,7 @@
Sylius\Behat\Context\Ui\Admin\ManagingLocalesContext
Sylius\Behat\Context\Ui\Admin\ManagingPaymentMethodsContext
Sylius\Behat\Context\Ui\Admin\ManagingProductAttributesContext
+ Sylius\Behat\Context\Ui\Admin\ManagingProductOptionsContext
Sylius\Behat\Context\Ui\Admin\ManagingPromotionsContext
Sylius\Behat\Context\Ui\Admin\ManagingShippingMethodsContext
Sylius\Behat\Context\Ui\Admin\ManagingTaxCategoriesContext
@@ -98,6 +99,15 @@
+
+
+
+
+
+
+
+
+
diff --git a/etc/behat/services/pages.xml b/etc/behat/services/pages.xml
index 60525eddb9..31d5bb365b 100644
--- a/etc/behat/services/pages.xml
+++ b/etc/behat/services/pages.xml
@@ -58,6 +58,9 @@
Sylius\Behat\Page\Admin\Product\Attribute\CreatePage
%sylius.behat.page.admin.crud.index.class%
Sylius\Behat\Page\Admin\Product\Attribute\UpdatePage
+ %sylius.behat.page.admin.crud.create.class%
+ %sylius.behat.page.admin.crud.update.class%
+ %sylius.behat.page.admin.crud.index.class%
Sylius\Behat\Page\Admin\Promotion\CreatePage
Sylius\Behat\Page\Admin\Promotion\UpdatePage
%sylius.behat.page.admin.crud.index.class%
@@ -148,6 +151,15 @@
payment_method
+
+ product_option
+
+
+ product_option
+
+
+ product_option
+
shipping_method
diff --git a/etc/behat/suites.yml b/etc/behat/suites.yml
index 50f863850b..70cc518d51 100644
--- a/etc/behat/suites.yml
+++ b/etc/behat/suites.yml
@@ -48,6 +48,7 @@ imports:
- suites/ui/payment/managing_payment_methods.yml
- suites/ui/product/managing_products.yml
- suites/ui/product/managing_product_attributes.yml
+ - suites/ui/product/managing_product_options.yml
- suites/ui/promotion/applying_promotion_rules.yml
- suites/ui/promotion/managing_promotions.yml
- suites/ui/promotion/receiving_discount.yml
diff --git a/etc/behat/suites/ui/product/managing_product_options.yml b/etc/behat/suites/ui/product/managing_product_options.yml
new file mode 100644
index 0000000000..8ec0e76ff6
--- /dev/null
+++ b/etc/behat/suites/ui/product/managing_product_options.yml
@@ -0,0 +1,17 @@
+# This file is part of the Sylius package.
+# (c) Paweł Jędrzejewski
+
+default:
+ suites:
+ ui_managing_product_options:
+ contexts_as_services:
+ - sylius.behat.context.hook.doctrine_orm
+
+ - sylius.behat.context.transform.shared_storage
+
+ - sylius.behat.context.setup.security
+ - sylius.behat.context.setup.product_option
+
+ - sylius.behat.context.ui.admin.managing_product_options
+ filters:
+ tags: "@managing_product_options && @ui"
diff --git a/src/Sylius/Behat/Context/Setup/ProductContext.php b/src/Sylius/Behat/Context/Setup/ProductContext.php
index 857ab92bf6..b56fbb5cb3 100644
--- a/src/Sylius/Behat/Context/Setup/ProductContext.php
+++ b/src/Sylius/Behat/Context/Setup/ProductContext.php
@@ -20,6 +20,7 @@ use Sylius\Component\Core\Model\ProductVariantInterface;
use Sylius\Component\Core\Repository\ProductRepositoryInterface;
use Sylius\Component\Core\Test\Services\SharedStorageInterface;
use Sylius\Component\Resource\Factory\FactoryInterface;
+use Sylius\Component\Resource\Repository\RepositoryInterface;
use Sylius\Component\Taxation\Model\TaxCategoryInterface;
/**
@@ -49,6 +50,16 @@ final class ProductContext implements Context
*/
private $productVariantFactory;
+ /**
+ * @var FactoryInterface
+ */
+ private $productOptionFactory;
+
+ /**
+ * @var RepositoryInterface
+ */
+ private $productOptionRepository;
+
/**
* @var ObjectManager
*/
@@ -59,6 +70,8 @@ final class ProductContext implements Context
* @param ProductRepositoryInterface $productRepository
* @param FactoryInterface $productFactory
* @param FactoryInterface $productVariantFactory
+ * @param FactoryInterface $productOptionFactory
+ * @param RepositoryInterface $productOptionRepository
* @param ObjectManager $objectManager
*/
public function __construct(
@@ -66,12 +79,16 @@ final class ProductContext implements Context
ProductRepositoryInterface $productRepository,
FactoryInterface $productFactory,
FactoryInterface $productVariantFactory,
+ FactoryInterface $productOptionFactory,
+ RepositoryInterface $productOptionRepository,
ObjectManager $objectManager
) {
$this->sharedStorage = $sharedStorage;
$this->productRepository = $productRepository;
$this->productFactory = $productFactory;
$this->productVariantFactory = $productVariantFactory;
+ $this->productOptionFactory = $productOptionFactory;
+ $this->productOptionRepository = $productOptionRepository;
$this->objectManager = $objectManager;
}
diff --git a/src/Sylius/Behat/Context/Transform/ProductOptionContext.php b/src/Sylius/Behat/Context/Transform/ProductOptionContext.php
new file mode 100644
index 0000000000..6852032d34
--- /dev/null
+++ b/src/Sylius/Behat/Context/Transform/ProductOptionContext.php
@@ -0,0 +1,52 @@
+
+ */
+final class ProductOptionContext implements Context
+{
+ /**
+ * @var RepositoryInterface
+ */
+ private $productOptionRepository;
+
+ /**
+ * @param RepositoryInterface $productOptionRepository
+ */
+ public function __construct(RepositoryInterface $productOptionRepository)
+ {
+ $this->productOptionRepository = $productOptionRepository;
+ }
+
+ /**
+ * @Transform /^product option "([^"]+)"$/
+ * @Transform :productOption
+ */
+ public function getProductOptionByName($productOptionName)
+ {
+ $productOption = $this->productOptionRepository->findOneBy(['name' => $productOptionName]);
+ if (null === $productOption) {
+ throw new \InvalidArgumentException(
+ sprintf('Product option with name "%s" does not exist in the product option repository.', $productOptionName)
+ );
+ }
+
+ return $productOption;
+ }
+}
diff --git a/src/Sylius/Behat/Context/Ui/Admin/ManagingProductOptionsContext.php b/src/Sylius/Behat/Context/Ui/Admin/ManagingProductOptionsContext.php
new file mode 100644
index 0000000000..6cd932855f
--- /dev/null
+++ b/src/Sylius/Behat/Context/Ui/Admin/ManagingProductOptionsContext.php
@@ -0,0 +1,119 @@
+
+ */
+final class ManagingProductOptionsContext implements Context
+{
+ const RESOURCE_NAME = 'product_option';
+
+ /**
+ * @var SharedStorageInterface
+ */
+ private $sharedStorage;
+
+ /**
+ * @var IndexPageInterface
+ */
+ private $indexPage;
+
+ /**
+ * @var CreatePageInterface
+ */
+ private $createPage;
+
+ /**
+ * @var UpdatePageInterface
+ */
+ private $updatePage;
+
+ /**
+ * @var CurrentPageResolverInterface
+ */
+ private $currentPageResolver;
+
+ /**
+ * @var NotificationCheckerInterface
+ */
+ private $notificationChecker;
+
+ /**
+ * @param SharedStorageInterface $sharedStorage
+ * @param IndexPageInterface $indexPage
+ * @param CreatePageInterface $createPage
+ * @param UpdatePageInterface $updatePage
+ * @param CurrentPageResolverInterface $currentPageResolver
+ * @param NotificationCheckerInterface $notificationChecker
+ */
+ public function __construct(
+ SharedStorageInterface $sharedStorage,
+ IndexPageInterface $indexPage,
+ CreatePageInterface $createPage,
+ UpdatePageInterface $updatePage,
+ CurrentPageResolverInterface $currentPageResolver,
+ NotificationCheckerInterface $notificationChecker
+ ) {
+ $this->sharedStorage = $sharedStorage;
+ $this->indexPage = $indexPage;
+ $this->createPage = $createPage;
+ $this->updatePage = $updatePage;
+ $this->currentPageResolver = $currentPageResolver;
+ $this->notificationChecker = $notificationChecker;
+ }
+
+ /**
+ * @Given I want to create a new product option
+ */
+ public function iWantToCreateANewProductOption()
+ {
+ $this->createPage->open();
+ }
+
+ /**
+ * @When I want to browse product options
+ */
+ public function iWantToBrowseProductOptions()
+ {
+ $this->indexPage->open();
+ }
+
+ /**
+ * @When I add it
+ * @When I try to add it
+ */
+ public function iAddIt()
+ {
+ $this->createPage->create();
+ }
+
+ /**
+ * @When I save my changes
+ * @When I try to save my changes
+ */
+ public function iSaveMyChanges()
+ {
+ $this->updatePage->saveChanges();
+ }
+}