mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 09:02:12 +00:00
[Admin][ProductOption] Added product option contexts configuration
This commit is contained in:
parent
8f93a11e11
commit
df7a475fa3
9 changed files with 231 additions and 0 deletions
|
|
@ -106,6 +106,8 @@
|
|||
<argument type="service" id="sylius.repository.product" container="symfony" />
|
||||
<argument type="service" id="sylius.factory.product" container="symfony" />
|
||||
<argument type="service" id="sylius.factory.product_variant" container="symfony" />
|
||||
<argument type="service" id="sylius.repository.product_option" container="symfony" />
|
||||
<argument type="service" id="sylius.factory.product_option" container="symfony" />
|
||||
<argument type="service" id="doctrine.orm.entity_manager" container="symfony" />
|
||||
<tag name="sylius.behat.context" />
|
||||
</service>
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
<parameter key="sylius.behat.context.transform.payment.class">Sylius\Behat\Context\Transform\PaymentContext</parameter>
|
||||
<parameter key="sylius.behat.context.transform.payment_method.class">Sylius\Behat\Context\Transform\PaymentMethodContext</parameter>
|
||||
<parameter key="sylius.behat.context.transform.product.class">Sylius\Behat\Context\Transform\ProductContext</parameter>
|
||||
<parameter key="sylius.behat.context.transform.product_option.class">Sylius\Behat\Context\Transform\ProductOptionContext</parameter>
|
||||
<parameter key="sylius.behat.context.transform.product_variant.class">Sylius\Behat\Context\Transform\ProductVariantContext</parameter>
|
||||
<parameter key="sylius.behat.context.transform.promotion.class">Sylius\Behat\Context\Transform\PromotionContext</parameter>
|
||||
<parameter key="sylius.behat.context.transform.province.class">Sylius\Behat\Context\Transform\ProvinceContext</parameter>
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
<parameter key="sylius.behat.context.ui.admin.managing_locales.class">Sylius\Behat\Context\Ui\Admin\ManagingLocalesContext</parameter>
|
||||
<parameter key="sylius.behat.context.ui.admin.managing_payment_methods.class">Sylius\Behat\Context\Ui\Admin\ManagingPaymentMethodsContext</parameter>
|
||||
<parameter key="sylius.behat.context.ui.admin.managing_product_attributes.class">Sylius\Behat\Context\Ui\Admin\ManagingProductAttributesContext</parameter>
|
||||
<parameter key="sylius.behat.context.ui.admin.managing_product_options.class">Sylius\Behat\Context\Ui\Admin\ManagingProductOptionsContext</parameter>
|
||||
<parameter key="sylius.behat.context.ui.admin.managing_promotions.class">Sylius\Behat\Context\Ui\Admin\ManagingPromotionsContext</parameter>
|
||||
<parameter key="sylius.behat.context.ui.admin.managing_shipping_methods.class">Sylius\Behat\Context\Ui\Admin\ManagingShippingMethodsContext</parameter>
|
||||
<parameter key="sylius.behat.context.ui.admin.managing_tax_categories.class">Sylius\Behat\Context\Ui\Admin\ManagingTaxCategoriesContext</parameter>
|
||||
|
|
@ -98,6 +99,15 @@
|
|||
<tag name="sylius.behat.context" />
|
||||
</service>
|
||||
|
||||
<service id="sylius.behat.context.ui.admin.managing_product_options" class="%sylius.behat.context.ui.admin.managing_product_options.class%" scope="scenario">
|
||||
<argument type="service" id="sylius.behat.page.admin.product_option.index" />
|
||||
<argument type="service" id="sylius.behat.page.admin.product_option.create" />
|
||||
<argument type="service" id="sylius.behat.page.admin.product_option.update" />
|
||||
<argument type="service" id="sylius.behat.current_page_resolver" />
|
||||
<argument type="service" id="sylius.behat.notification_checker" />
|
||||
<tag name="sylius.behat.context" />
|
||||
</service>
|
||||
|
||||
<service id="sylius.behat.context.ui.admin.managing_promotions" class="%sylius.behat.context.ui.admin.managing_promotions.class%" scope="scenario">
|
||||
<argument type="service" id="sylius.behat.shared_storage" container="symfony" />
|
||||
<argument type="service" id="sylius.behat.page.admin.promotion.index" />
|
||||
|
|
|
|||
|
|
@ -58,6 +58,9 @@
|
|||
<parameter key="sylius.behat.page.admin.product_attribute.create.class">Sylius\Behat\Page\Admin\Product\Attribute\CreatePage</parameter>
|
||||
<parameter key="sylius.behat.page.admin.product_attribute.index.class">%sylius.behat.page.admin.crud.index.class%</parameter>
|
||||
<parameter key="sylius.behat.page.admin.product_attribute.update.class">Sylius\Behat\Page\Admin\Product\Attribute\UpdatePage</parameter>
|
||||
<parameter key="sylius.behat.page.admin.product_option.create.class">%sylius.behat.page.admin.crud.create.class%</parameter>
|
||||
<parameter key="sylius.behat.page.admin.product_option.update.class">%sylius.behat.page.admin.crud.update.class%</parameter>
|
||||
<parameter key="sylius.behat.page.admin.product_option.index.class">%sylius.behat.page.admin.crud.index.class%</parameter>
|
||||
<parameter key="sylius.behat.page.admin.promotion.create.class">Sylius\Behat\Page\Admin\Promotion\CreatePage</parameter>
|
||||
<parameter key="sylius.behat.page.admin.promotion.update.class">Sylius\Behat\Page\Admin\Promotion\UpdatePage</parameter>
|
||||
<parameter key="sylius.behat.page.admin.promotion.index.class">%sylius.behat.page.admin.crud.index.class%</parameter>
|
||||
|
|
@ -148,6 +151,15 @@
|
|||
<service id="sylius.behat.page.admin.payment_method.update" class="%sylius.behat.page.admin.payment_method.update.class%" parent="sylius.behat.page.admin.crud.update" scope="scenario" public="false">
|
||||
<argument type="string">payment_method</argument>
|
||||
</service>
|
||||
<service id="sylius.behat.page.admin.product_option.create" class="%sylius.behat.page.admin.product_option.create.class%" parent="sylius.behat.page.admin.crud.create" scope="scenario" public="false">
|
||||
<argument type="string">product_option</argument>
|
||||
</service>
|
||||
<service id="sylius.behat.page.admin.product_option.update" class="%sylius.behat.page.admin.product_option.update.class%" parent="sylius.behat.page.admin.crud.update" scope="scenario" public="false">
|
||||
<argument type="string">product_option</argument>
|
||||
</service>
|
||||
<service id="sylius.behat.page.admin.product_option.index" class="%sylius.behat.page.admin.product_option.index.class%" parent="sylius.behat.page.admin.crud.index" scope="scenario" public="false">
|
||||
<argument type="string">product_option</argument>
|
||||
</service>
|
||||
<service id="sylius.behat.page.admin.shipping_method.create" class="%sylius.behat.page.admin.shipping_method.create.class%" parent="sylius.behat.page.admin.crud.create" scope="scenario" public="false">
|
||||
<argument type="string">shipping_method</argument>
|
||||
</service>
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
17
etc/behat/suites/ui/product/managing_product_options.yml
Normal file
17
etc/behat/suites/ui/product/managing_product_options.yml
Normal file
|
|
@ -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"
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
52
src/Sylius/Behat/Context/Transform/ProductOptionContext.php
Normal file
52
src/Sylius/Behat/Context/Transform/ProductOptionContext.php
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Behat\Context\Transform;
|
||||
|
||||
use Behat\Behat\Context\Context;
|
||||
use Sylius\Component\Core\Repository\ProductRepositoryInterface;
|
||||
use Sylius\Component\Core\Repository\ProductVariantRepositoryInterface;
|
||||
use Sylius\Component\Resource\Repository\RepositoryInterface;
|
||||
|
||||
/**
|
||||
* @author Grzegorz Sadowski <grzegorz.sadowski@lakion.com>
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,119 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Behat\Context\Ui\Admin;
|
||||
|
||||
use Behat\Behat\Context\Context;
|
||||
use Sylius\Behat\Page\Admin\Crud\IndexPageInterface;
|
||||
use Sylius\Behat\Page\Admin\Crud\CreatePageInterface;
|
||||
use Sylius\Behat\Page\Admin\Crud\UpdatePageInterface;
|
||||
use Sylius\Behat\Service\CurrentPageResolverInterface;
|
||||
use Sylius\Behat\Service\NotificationCheckerInterface;
|
||||
use Sylius\Behat\NotificationType;
|
||||
use Sylius\Component\Core\Model\ShippingMethodInterface;
|
||||
use Sylius\Component\Core\Test\Services\SharedStorageInterface;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
/**
|
||||
* @author Grzegorz Sadowski <grzegorz.sadowski@lakion.com>
|
||||
*/
|
||||
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();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue