diff --git a/features/channel/managing_channels/adding_new_channel_with_menu_taxon.feature b/features/channel/managing_channels/adding_new_channel_with_menu_taxon.feature
new file mode 100644
index 0000000000..4d23169530
--- /dev/null
+++ b/features/channel/managing_channels/adding_new_channel_with_menu_taxon.feature
@@ -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
diff --git a/features/channel/managing_channels/editing_menu_taxon_on_channel.feature b/features/channel/managing_channels/editing_menu_taxon_on_channel.feature
new file mode 100644
index 0000000000..16e012e561
--- /dev/null
+++ b/features/channel/managing_channels/editing_menu_taxon_on_channel.feature
@@ -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"
diff --git a/features/taxonomy/managing_taxons/deleting_taxon.feature b/features/taxonomy/managing_taxons/deleting_taxon.feature
index bd8245105e..fe6ea9f17e 100644
--- a/features/taxonomy/managing_taxons/deleting_taxon.feature
+++ b/features/taxonomy/managing_taxons/deleting_taxon.feature
@@ -23,3 +23,11 @@ Feature: Deleting a taxon
And the taxon named "Men" 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
+
+ @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
diff --git a/src/Sylius/Behat/Context/Setup/ChannelContext.php b/src/Sylius/Behat/Context/Setup/ChannelContext.php
index e8e841e4b0..da97c352e5 100644
--- a/src/Sylius/Behat/Context/Setup/ChannelContext.php
+++ b/src/Sylius/Behat/Context/Setup/ChannelContext.php
@@ -22,6 +22,7 @@ use Sylius\Component\Channel\Repository\ChannelRepositoryInterface;
use Sylius\Component\Core\Formatter\StringInflector;
use Sylius\Component\Core\Model\ChannelInterface;
use Sylius\Component\Core\Model\ShopBillingData;
+use Sylius\Component\Core\Model\TaxonInterface;
use Sylius\Component\Core\Test\Services\DefaultChannelFactoryInterface;
final class ChannelContext implements Context
@@ -222,6 +223,18 @@ final class ChannelContext implements Context
public function theChannelIsAType(ChannelInterface $channel, string $type): void
{
$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();
}
/**
diff --git a/src/Sylius/Behat/Context/Ui/Admin/ManagingChannelsContext.php b/src/Sylius/Behat/Context/Ui/Admin/ManagingChannelsContext.php
index 293e0bfd0a..8bcd09b9fd 100644
--- a/src/Sylius/Behat/Context/Ui/Admin/ManagingChannelsContext.php
+++ b/src/Sylius/Behat/Context/Ui/Admin/ManagingChannelsContext.php
@@ -102,6 +102,22 @@ final class ManagingChannelsContext implements Context
$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
*/
@@ -516,6 +532,19 @@ final class ManagingChannelsContext implements Context
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
*/
diff --git a/src/Sylius/Behat/Context/Ui/Admin/ManagingTaxonsContext.php b/src/Sylius/Behat/Context/Ui/Admin/ManagingTaxonsContext.php
index 03c7959748..3c7f3263d7 100644
--- a/src/Sylius/Behat/Context/Ui/Admin/ManagingTaxonsContext.php
+++ b/src/Sylius/Behat/Context/Ui/Admin/ManagingTaxonsContext.php
@@ -14,9 +14,11 @@ declare(strict_types=1);
namespace Sylius\Behat\Context\Ui\Admin;
use Behat\Behat\Context\Context;
+use Sylius\Behat\NotificationType;
use Sylius\Behat\Page\Admin\Taxon\CreateForParentPageInterface;
use Sylius\Behat\Page\Admin\Taxon\CreatePageInterface;
use Sylius\Behat\Page\Admin\Taxon\UpdatePageInterface;
+use Sylius\Behat\Service\NotificationCheckerInterface;
use Sylius\Behat\Service\Resolver\CurrentPageResolverInterface;
use Sylius\Behat\Service\SharedStorageInterface;
use Sylius\Component\Core\Model\TaxonInterface;
@@ -39,18 +41,23 @@ final class ManagingTaxonsContext implements Context
/** @var CurrentPageResolverInterface */
private $currentPageResolver;
+ /** @var NotificationCheckerInterface */
+ private $notificationChecker;
+
public function __construct(
SharedStorageInterface $sharedStorage,
CreatePageInterface $createPage,
CreateForParentPageInterface $createForParentPage,
UpdatePageInterface $updatePage,
- CurrentPageResolverInterface $currentPageResolver
+ CurrentPageResolverInterface $currentPageResolver,
+ NotificationCheckerInterface $notificationChecker
) {
$this->sharedStorage = $sharedStorage;
$this->createPage = $createPage;
$this->createForParentPage = $createForParentPage;
$this->updatePage = $updatePage;
$this->currentPageResolver = $currentPageResolver;
+ $this->notificationChecker = $notificationChecker;
}
/**
@@ -380,6 +387,17 @@ final class ManagingTaxonsContext implements Context
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
*/
diff --git a/src/Sylius/Behat/Page/Admin/Channel/CreatePage.php b/src/Sylius/Behat/Page/Admin/Channel/CreatePage.php
index 342b6abc16..98a277997f 100644
--- a/src/Sylius/Behat/Page/Admin/Channel/CreatePage.php
+++ b/src/Sylius/Behat/Page/Admin/Channel/CreatePage.php
@@ -92,6 +92,11 @@ class CreatePage extends BaseCreatePage implements CreatePageInterface
$this->getElement('type')->selectOption($type);
}
+ public function specifyMenuTaxon(string $menuTaxon): void
+ {
+ $this->getElement('menu_taxon')->selectOption($menuTaxon);
+ }
+
protected function getToggleableElement(): NodeElement
{
return $this->getElement('enabled');
@@ -106,6 +111,7 @@ class CreatePage extends BaseCreatePage implements CreatePageInterface
'default_locale' => '#sylius_channel_defaultLocale',
'enabled' => '#sylius_channel_enabled',
'locales' => '#sylius_channel_locales',
+ 'menu_taxon' => '#sylius_channel_menuTaxon',
'name' => '#sylius_channel_name',
'type' => '#sylius_channel_type',
]);
diff --git a/src/Sylius/Behat/Page/Admin/Channel/CreatePageInterface.php b/src/Sylius/Behat/Page/Admin/Channel/CreatePageInterface.php
index 93f36c7b7f..4009765653 100644
--- a/src/Sylius/Behat/Page/Admin/Channel/CreatePageInterface.php
+++ b/src/Sylius/Behat/Page/Admin/Channel/CreatePageInterface.php
@@ -50,4 +50,6 @@ interface CreatePageInterface extends BaseCreatePageInterface
public function allowToSkipPaymentStep(): void;
public function setType(string $type): void;
+
+ public function specifyMenuTaxon(string $menuTaxon): void;
}
diff --git a/src/Sylius/Behat/Page/Admin/Channel/UpdatePage.php b/src/Sylius/Behat/Page/Admin/Channel/UpdatePage.php
index a82ecb846c..cc6fc59bd7 100644
--- a/src/Sylius/Behat/Page/Admin/Channel/UpdatePage.php
+++ b/src/Sylius/Behat/Page/Admin/Channel/UpdatePage.php
@@ -97,6 +97,16 @@ class UpdatePage extends BaseUpdatePage implements UpdatePageInterface
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
{
return $this->getElement('theme')->getValue();
@@ -122,6 +132,7 @@ class UpdatePage extends BaseUpdatePage implements UpdatePageInterface
'default_tax_zone' => '#sylius_channel_defaultTaxZone',
'enabled' => '#sylius_channel_enabled',
'locales' => '#sylius_channel_locales',
+ 'menu_taxon' => '#sylius_channel_menuTaxon',
'name' => '#sylius_channel_name',
'tax_calculation_strategy' => '#sylius_channel_taxCalculationStrategy',
'theme' => '#sylius_channel_themeName',
diff --git a/src/Sylius/Behat/Page/Admin/Channel/UpdatePageInterface.php b/src/Sylius/Behat/Page/Admin/Channel/UpdatePageInterface.php
index 346cf0f952..e004b86ead 100644
--- a/src/Sylius/Behat/Page/Admin/Channel/UpdatePageInterface.php
+++ b/src/Sylius/Behat/Page/Admin/Channel/UpdatePageInterface.php
@@ -55,5 +55,9 @@ interface UpdatePageInterface extends BaseUpdatePageInterface
public function getType(): string;
+ public function changeMenuTaxon(string $menuTaxon): void;
+
+ public function getMenuTaxon(): string;
+
public function getUsedTheme(): string;
}
diff --git a/src/Sylius/Behat/Resources/config/services/contexts/ui.xml b/src/Sylius/Behat/Resources/config/services/contexts/ui.xml
index 1138dcdbe8..d9f443e6ed 100644
--- a/src/Sylius/Behat/Resources/config/services/contexts/ui.xml
+++ b/src/Sylius/Behat/Resources/config/services/contexts/ui.xml
@@ -252,6 +252,7 @@
+
diff --git a/src/Sylius/Behat/Resources/config/suites/ui/channel/managing_channels.yml b/src/Sylius/Behat/Resources/config/suites/ui/channel/managing_channels.yml
index 72f255b404..cd81bab3a7 100644
--- a/src/Sylius/Behat/Resources/config/suites/ui/channel/managing_channels.yml
+++ b/src/Sylius/Behat/Resources/config/suites/ui/channel/managing_channels.yml
@@ -13,6 +13,7 @@ default:
- sylius.behat.context.transform.currency
- sylius.behat.context.transform.locale
- sylius.behat.context.transform.shared_storage
+ - sylius.behat.context.transform.taxon
- sylius.behat.context.transform.zone
- sylius.behat.context.setup.channel
@@ -22,6 +23,7 @@ default:
- sylius.behat.context.setup.payment
- sylius.behat.context.setup.admin_security
- sylius.behat.context.setup.shipping
+ - sylius.behat.context.setup.taxonomy
- sylius.behat.context.setup.zone
- sylius.behat.context.ui.admin.managing_channels
diff --git a/src/Sylius/Behat/Resources/config/suites/ui/taxonomy/managing_taxons.yml b/src/Sylius/Behat/Resources/config/suites/ui/taxonomy/managing_taxons.yml
index 7e33976193..b65ca8a8c9 100644
--- a/src/Sylius/Behat/Resources/config/suites/ui/taxonomy/managing_taxons.yml
+++ b/src/Sylius/Behat/Resources/config/suites/ui/taxonomy/managing_taxons.yml
@@ -7,10 +7,12 @@ default:
contexts:
- sylius.behat.context.hook.doctrine_orm
+ - sylius.behat.context.transform.channel
- sylius.behat.context.transform.locale
- sylius.behat.context.transform.shared_storage
- sylius.behat.context.transform.taxon
+ - sylius.behat.context.setup.channel
- sylius.behat.context.setup.locale
- sylius.behat.context.setup.admin_security
- sylius.behat.context.setup.taxonomy