mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 09:02:12 +00:00
[Behat] Managing menu taxon on channel scenarios
This commit is contained in:
parent
1066169bcb
commit
1d2361571e
13 changed files with 144 additions and 1 deletions
|
|
@ -0,0 +1,27 @@
|
||||||
|
@managing_channels
|
||||||
|
Feature: Adding a new channel with menu taxon
|
||||||
|
In order to sell through multiple channels of distributions products only from specific categories
|
||||||
|
As an Administrator
|
||||||
|
I want to add a new channel with a menu taxon
|
||||||
|
|
||||||
|
Background:
|
||||||
|
Given the store has currency "Euro"
|
||||||
|
And the store has locale "English (United States)"
|
||||||
|
And the store operates in "United States"
|
||||||
|
And the store classifies its products as "Clothes" and "Guns"
|
||||||
|
And I am logged in as an administrator
|
||||||
|
|
||||||
|
@ui
|
||||||
|
Scenario: Adding a new channel with menu taxon
|
||||||
|
Given I want to create a new channel
|
||||||
|
When I specify its code as "MOBILE"
|
||||||
|
And I name it "Mobile channel"
|
||||||
|
And I choose "Euro" as the base currency
|
||||||
|
And I choose "English (United States)" as a default locale
|
||||||
|
And I specify company as "Ragnarok"
|
||||||
|
And I specify tax ID as "1100110011"
|
||||||
|
And I specify menu taxon as "Clothes"
|
||||||
|
And I add it
|
||||||
|
Then I should be notified that it has been successfully created
|
||||||
|
And the channel "Mobile channel" should appear in the registry
|
||||||
|
And the channel "Mobile channel" should have "Clothes" as a menu taxon
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
@managing_channels
|
||||||
|
Feature: Editing menu taxon on channel
|
||||||
|
In order to have proper products' categories displayed on each channel
|
||||||
|
As an Administrator
|
||||||
|
I want to be able to edit menu taxon on a channel
|
||||||
|
|
||||||
|
Background:
|
||||||
|
Given the store operates on a channel named "Web Store"
|
||||||
|
And the store ships to "United States"
|
||||||
|
And the store classifies its products as "Clothes" and "Guns"
|
||||||
|
And channel "Web Store" has menu taxon "Clothes"
|
||||||
|
And I am logged in as an administrator
|
||||||
|
|
||||||
|
@ui
|
||||||
|
Scenario: Editing menu taxon on the channel
|
||||||
|
When I want to modify a channel "Web Store"
|
||||||
|
And I change its menu taxon to "Guns"
|
||||||
|
And I save my changes
|
||||||
|
Then I should be notified that it has been successfully edited
|
||||||
|
And this channel menu taxon should be "Guns"
|
||||||
|
|
@ -23,3 +23,11 @@ Feature: Deleting a taxon
|
||||||
And the taxon named "Men" should no longer exist in the registry
|
And the taxon named "Men" should no longer exist in the registry
|
||||||
And the taxon named "Women" should no longer exist in the registry
|
And the taxon named "Women" should no longer exist in the registry
|
||||||
But the "Shovels" taxon should appear in the registry
|
But the "Shovels" taxon should appear in the registry
|
||||||
|
|
||||||
|
@ui
|
||||||
|
Scenario: Deleted taxon should disappear from the registry
|
||||||
|
Given the store classifies its products as "T-Shirts" and "Caps"
|
||||||
|
And the store operates on a channel named "Web Store"
|
||||||
|
And channel "Web Store" has menu taxon "Caps"
|
||||||
|
When I delete taxon named "Caps"
|
||||||
|
Then I should be notified that I cannot delete a menu taxon of any channel
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ use Sylius\Component\Channel\Repository\ChannelRepositoryInterface;
|
||||||
use Sylius\Component\Core\Formatter\StringInflector;
|
use Sylius\Component\Core\Formatter\StringInflector;
|
||||||
use Sylius\Component\Core\Model\ChannelInterface;
|
use Sylius\Component\Core\Model\ChannelInterface;
|
||||||
use Sylius\Component\Core\Model\ShopBillingData;
|
use Sylius\Component\Core\Model\ShopBillingData;
|
||||||
|
use Sylius\Component\Core\Model\TaxonInterface;
|
||||||
use Sylius\Component\Core\Test\Services\DefaultChannelFactoryInterface;
|
use Sylius\Component\Core\Test\Services\DefaultChannelFactoryInterface;
|
||||||
|
|
||||||
final class ChannelContext implements Context
|
final class ChannelContext implements Context
|
||||||
|
|
@ -222,6 +223,18 @@ final class ChannelContext implements Context
|
||||||
public function theChannelIsAType(ChannelInterface $channel, string $type): void
|
public function theChannelIsAType(ChannelInterface $channel, string $type): void
|
||||||
{
|
{
|
||||||
$channel->setType($type);
|
$channel->setType($type);
|
||||||
|
|
||||||
|
$this->channelManager->flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Given /^(channel "[^"]+") has menu (taxon "[^"]+")$/
|
||||||
|
*/
|
||||||
|
public function theChannelMenuTaxonIs(ChannelInterface $channel, TaxonInterface $taxon): void
|
||||||
|
{
|
||||||
|
$channel->setMenuTaxon($taxon);
|
||||||
|
|
||||||
|
$this->channelManager->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -102,6 +102,22 @@ final class ManagingChannelsContext implements Context
|
||||||
$this->createPage->chooseDefaultLocale($locale);
|
$this->createPage->chooseDefaultLocale($locale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @When I specify menu taxon as :menuTaxon
|
||||||
|
*/
|
||||||
|
public function iSpecifyMenuTaxonAs(string $menuTaxon): void
|
||||||
|
{
|
||||||
|
$this->createPage->specifyMenuTaxon($menuTaxon);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @When I change its menu taxon to :menuTaxon
|
||||||
|
*/
|
||||||
|
public function iChangeMenuTaxonTo(string $menuTaxon): void
|
||||||
|
{
|
||||||
|
$this->updatePage->changeMenuTaxon($menuTaxon);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @When I allow to skip shipping step if only one shipping method is available
|
* @When I allow to skip shipping step if only one shipping method is available
|
||||||
*/
|
*/
|
||||||
|
|
@ -516,6 +532,19 @@ final class ManagingChannelsContext implements Context
|
||||||
Assert::same($this->updatePage->getType(), $type);
|
Assert::same($this->updatePage->getType(), $type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Given /^(this channel) menu taxon should be "([^"]+)"$/
|
||||||
|
* @Given /^the (channel "[^"]+") should have "([^"]+)" as a menu taxon$/
|
||||||
|
*/
|
||||||
|
public function thisChannelMenuTaxonShouldBe(ChannelInterface $channel, string $menuTaxon): void
|
||||||
|
{
|
||||||
|
if (!$this->updatePage->isOpen(['id' => $channel->getId()])) {
|
||||||
|
$this->updatePage->open(['id' => $channel->getId()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Assert::same($this->updatePage->getMenuTaxon(), $menuTaxon);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param bool $state
|
* @param bool $state
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -14,9 +14,11 @@ declare(strict_types=1);
|
||||||
namespace Sylius\Behat\Context\Ui\Admin;
|
namespace Sylius\Behat\Context\Ui\Admin;
|
||||||
|
|
||||||
use Behat\Behat\Context\Context;
|
use Behat\Behat\Context\Context;
|
||||||
|
use Sylius\Behat\NotificationType;
|
||||||
use Sylius\Behat\Page\Admin\Taxon\CreateForParentPageInterface;
|
use Sylius\Behat\Page\Admin\Taxon\CreateForParentPageInterface;
|
||||||
use Sylius\Behat\Page\Admin\Taxon\CreatePageInterface;
|
use Sylius\Behat\Page\Admin\Taxon\CreatePageInterface;
|
||||||
use Sylius\Behat\Page\Admin\Taxon\UpdatePageInterface;
|
use Sylius\Behat\Page\Admin\Taxon\UpdatePageInterface;
|
||||||
|
use Sylius\Behat\Service\NotificationCheckerInterface;
|
||||||
use Sylius\Behat\Service\Resolver\CurrentPageResolverInterface;
|
use Sylius\Behat\Service\Resolver\CurrentPageResolverInterface;
|
||||||
use Sylius\Behat\Service\SharedStorageInterface;
|
use Sylius\Behat\Service\SharedStorageInterface;
|
||||||
use Sylius\Component\Core\Model\TaxonInterface;
|
use Sylius\Component\Core\Model\TaxonInterface;
|
||||||
|
|
@ -39,18 +41,23 @@ final class ManagingTaxonsContext implements Context
|
||||||
/** @var CurrentPageResolverInterface */
|
/** @var CurrentPageResolverInterface */
|
||||||
private $currentPageResolver;
|
private $currentPageResolver;
|
||||||
|
|
||||||
|
/** @var NotificationCheckerInterface */
|
||||||
|
private $notificationChecker;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
SharedStorageInterface $sharedStorage,
|
SharedStorageInterface $sharedStorage,
|
||||||
CreatePageInterface $createPage,
|
CreatePageInterface $createPage,
|
||||||
CreateForParentPageInterface $createForParentPage,
|
CreateForParentPageInterface $createForParentPage,
|
||||||
UpdatePageInterface $updatePage,
|
UpdatePageInterface $updatePage,
|
||||||
CurrentPageResolverInterface $currentPageResolver
|
CurrentPageResolverInterface $currentPageResolver,
|
||||||
|
NotificationCheckerInterface $notificationChecker
|
||||||
) {
|
) {
|
||||||
$this->sharedStorage = $sharedStorage;
|
$this->sharedStorage = $sharedStorage;
|
||||||
$this->createPage = $createPage;
|
$this->createPage = $createPage;
|
||||||
$this->createForParentPage = $createForParentPage;
|
$this->createForParentPage = $createForParentPage;
|
||||||
$this->updatePage = $updatePage;
|
$this->updatePage = $updatePage;
|
||||||
$this->currentPageResolver = $currentPageResolver;
|
$this->currentPageResolver = $currentPageResolver;
|
||||||
|
$this->notificationChecker = $notificationChecker;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -380,6 +387,17 @@ final class ManagingTaxonsContext implements Context
|
||||||
Assert::same($this->updatePage->countImages(), (int) $count);
|
Assert::same($this->updatePage->countImages(), (int) $count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Then I should be notified that I cannot delete a menu taxon of any channel
|
||||||
|
*/
|
||||||
|
public function iShouldBeNotifiedThatICannotDeleteAMenuTaxonOfAnyChannel(): void
|
||||||
|
{
|
||||||
|
$this->notificationChecker->checkNotification(
|
||||||
|
'You cannot delete a menu taxon of any channel',
|
||||||
|
NotificationType::failure()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return CreatePageInterface|CreateForParentPageInterface|UpdatePageInterface
|
* @return CreatePageInterface|CreateForParentPageInterface|UpdatePageInterface
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -92,6 +92,11 @@ class CreatePage extends BaseCreatePage implements CreatePageInterface
|
||||||
$this->getElement('type')->selectOption($type);
|
$this->getElement('type')->selectOption($type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function specifyMenuTaxon(string $menuTaxon): void
|
||||||
|
{
|
||||||
|
$this->getElement('menu_taxon')->selectOption($menuTaxon);
|
||||||
|
}
|
||||||
|
|
||||||
protected function getToggleableElement(): NodeElement
|
protected function getToggleableElement(): NodeElement
|
||||||
{
|
{
|
||||||
return $this->getElement('enabled');
|
return $this->getElement('enabled');
|
||||||
|
|
@ -106,6 +111,7 @@ class CreatePage extends BaseCreatePage implements CreatePageInterface
|
||||||
'default_locale' => '#sylius_channel_defaultLocale',
|
'default_locale' => '#sylius_channel_defaultLocale',
|
||||||
'enabled' => '#sylius_channel_enabled',
|
'enabled' => '#sylius_channel_enabled',
|
||||||
'locales' => '#sylius_channel_locales',
|
'locales' => '#sylius_channel_locales',
|
||||||
|
'menu_taxon' => '#sylius_channel_menuTaxon',
|
||||||
'name' => '#sylius_channel_name',
|
'name' => '#sylius_channel_name',
|
||||||
'type' => '#sylius_channel_type',
|
'type' => '#sylius_channel_type',
|
||||||
]);
|
]);
|
||||||
|
|
|
||||||
|
|
@ -50,4 +50,6 @@ interface CreatePageInterface extends BaseCreatePageInterface
|
||||||
public function allowToSkipPaymentStep(): void;
|
public function allowToSkipPaymentStep(): void;
|
||||||
|
|
||||||
public function setType(string $type): void;
|
public function setType(string $type): void;
|
||||||
|
|
||||||
|
public function specifyMenuTaxon(string $menuTaxon): void;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -97,6 +97,16 @@ class UpdatePage extends BaseUpdatePage implements UpdatePageInterface
|
||||||
return $this->getElement('type')->getValue();
|
return $this->getElement('type')->getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function changeMenuTaxon(string $menuTaxon): void
|
||||||
|
{
|
||||||
|
$this->getElement('menu_taxon')->selectOption($menuTaxon);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMenuTaxon(): string
|
||||||
|
{
|
||||||
|
return $this->getElement('menu_taxon')->find('css', 'option:selected')->getText();
|
||||||
|
}
|
||||||
|
|
||||||
public function getUsedTheme(): string
|
public function getUsedTheme(): string
|
||||||
{
|
{
|
||||||
return $this->getElement('theme')->getValue();
|
return $this->getElement('theme')->getValue();
|
||||||
|
|
@ -122,6 +132,7 @@ class UpdatePage extends BaseUpdatePage implements UpdatePageInterface
|
||||||
'default_tax_zone' => '#sylius_channel_defaultTaxZone',
|
'default_tax_zone' => '#sylius_channel_defaultTaxZone',
|
||||||
'enabled' => '#sylius_channel_enabled',
|
'enabled' => '#sylius_channel_enabled',
|
||||||
'locales' => '#sylius_channel_locales',
|
'locales' => '#sylius_channel_locales',
|
||||||
|
'menu_taxon' => '#sylius_channel_menuTaxon',
|
||||||
'name' => '#sylius_channel_name',
|
'name' => '#sylius_channel_name',
|
||||||
'tax_calculation_strategy' => '#sylius_channel_taxCalculationStrategy',
|
'tax_calculation_strategy' => '#sylius_channel_taxCalculationStrategy',
|
||||||
'theme' => '#sylius_channel_themeName',
|
'theme' => '#sylius_channel_themeName',
|
||||||
|
|
|
||||||
|
|
@ -55,5 +55,9 @@ interface UpdatePageInterface extends BaseUpdatePageInterface
|
||||||
|
|
||||||
public function getType(): string;
|
public function getType(): string;
|
||||||
|
|
||||||
|
public function changeMenuTaxon(string $menuTaxon): void;
|
||||||
|
|
||||||
|
public function getMenuTaxon(): string;
|
||||||
|
|
||||||
public function getUsedTheme(): string;
|
public function getUsedTheme(): string;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -252,6 +252,7 @@
|
||||||
<argument type="service" id="sylius.behat.page.admin.taxon.create_for_parent" />
|
<argument type="service" id="sylius.behat.page.admin.taxon.create_for_parent" />
|
||||||
<argument type="service" id="sylius.behat.page.admin.taxon.update" />
|
<argument type="service" id="sylius.behat.page.admin.taxon.update" />
|
||||||
<argument type="service" id="sylius.behat.current_page_resolver" />
|
<argument type="service" id="sylius.behat.current_page_resolver" />
|
||||||
|
<argument type="service" id="sylius.behat.notification_checker" />
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
<service id="sylius.behat.context.ui.admin.managing_tax_rate" class="Sylius\Behat\Context\Ui\Admin\ManagingTaxRateContext">
|
<service id="sylius.behat.context.ui.admin.managing_tax_rate" class="Sylius\Behat\Context\Ui\Admin\ManagingTaxRateContext">
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ default:
|
||||||
- sylius.behat.context.transform.currency
|
- sylius.behat.context.transform.currency
|
||||||
- sylius.behat.context.transform.locale
|
- sylius.behat.context.transform.locale
|
||||||
- sylius.behat.context.transform.shared_storage
|
- sylius.behat.context.transform.shared_storage
|
||||||
|
- sylius.behat.context.transform.taxon
|
||||||
- sylius.behat.context.transform.zone
|
- sylius.behat.context.transform.zone
|
||||||
|
|
||||||
- sylius.behat.context.setup.channel
|
- sylius.behat.context.setup.channel
|
||||||
|
|
@ -22,6 +23,7 @@ default:
|
||||||
- sylius.behat.context.setup.payment
|
- sylius.behat.context.setup.payment
|
||||||
- sylius.behat.context.setup.admin_security
|
- sylius.behat.context.setup.admin_security
|
||||||
- sylius.behat.context.setup.shipping
|
- sylius.behat.context.setup.shipping
|
||||||
|
- sylius.behat.context.setup.taxonomy
|
||||||
- sylius.behat.context.setup.zone
|
- sylius.behat.context.setup.zone
|
||||||
|
|
||||||
- sylius.behat.context.ui.admin.managing_channels
|
- sylius.behat.context.ui.admin.managing_channels
|
||||||
|
|
|
||||||
|
|
@ -7,10 +7,12 @@ default:
|
||||||
contexts:
|
contexts:
|
||||||
- sylius.behat.context.hook.doctrine_orm
|
- sylius.behat.context.hook.doctrine_orm
|
||||||
|
|
||||||
|
- sylius.behat.context.transform.channel
|
||||||
- sylius.behat.context.transform.locale
|
- sylius.behat.context.transform.locale
|
||||||
- sylius.behat.context.transform.shared_storage
|
- sylius.behat.context.transform.shared_storage
|
||||||
- sylius.behat.context.transform.taxon
|
- sylius.behat.context.transform.taxon
|
||||||
|
|
||||||
|
- sylius.behat.context.setup.channel
|
||||||
- sylius.behat.context.setup.locale
|
- sylius.behat.context.setup.locale
|
||||||
- sylius.behat.context.setup.admin_security
|
- sylius.behat.context.setup.admin_security
|
||||||
- sylius.behat.context.setup.taxonomy
|
- sylius.behat.context.setup.taxonomy
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue