From 3bd9b1ce5c43ad84b91f3fcb1c1ead2d55bee001 Mon Sep 17 00:00:00 2001 From: Luca Gallinari Date: Mon, 30 Mar 2020 11:55:15 +0200 Subject: [PATCH] Improves managing taxons disable/enable feature --- .../disable_or_enable_taxon.feature | 18 +++++++++++++++ .../Behat/Context/Setup/TaxonomyContext.php | 22 +++++++++++++++++++ .../Ui/Admin/ManagingTaxonsContext.php | 18 ++++++++++++++- .../Behat/Page/Admin/Taxon/UpdatePage.php | 5 +++++ .../Page/Admin/Taxon/UpdatePageInterface.php | 2 ++ 5 files changed, 64 insertions(+), 1 deletion(-) diff --git a/features/taxonomy/managing_taxons/disable_or_enable_taxon.feature b/features/taxonomy/managing_taxons/disable_or_enable_taxon.feature index 73d6307f2c..3fe376a4c5 100644 --- a/features/taxonomy/managing_taxons/disable_or_enable_taxon.feature +++ b/features/taxonomy/managing_taxons/disable_or_enable_taxon.feature @@ -20,3 +20,21 @@ Feature: Toggle the taxon Then I should be notified that it has been successfully created And the "Jeans" taxon should appear in the registry And it should be marked as disabled + + @ui + Scenario: Enabling a Taxon + Given the "T-Shirts" taxon is disabled + And I want to modify the "T-Shirts" taxon + When I enable it + And I save my changes + Then I should be notified that it has been successfully edited + And it should be marked as enabled + + @ui + Scenario: Disabling a Taxon + Given the "T-Shirts" taxon is enabled + And I want to modify the "T-Shirts" taxon + When I disable it + And I save my changes + Then I should be notified that it has been successfully edited + And it should be marked as disabled diff --git a/src/Sylius/Behat/Context/Setup/TaxonomyContext.php b/src/Sylius/Behat/Context/Setup/TaxonomyContext.php index b8572b2b64..60593b960c 100644 --- a/src/Sylius/Behat/Context/Setup/TaxonomyContext.php +++ b/src/Sylius/Behat/Context/Setup/TaxonomyContext.php @@ -139,6 +139,28 @@ final class TaxonomyContext implements Context $this->objectManager->flush(); } + /** + * @Given /^the ("[^"]+" taxon)(?:| also) is enabled/ + */ + public function theTaxonIsEnabled(TaxonInterface $taxon) + { + $taxon->setEnabled(true); + + $this->objectManager->persist($taxon); + $this->objectManager->flush(); + } + + /** + * @Given /^the ("[^"]+" taxon)(?:| also) is disabled$/ + */ + public function theTaxonIsDisabled(TaxonInterface $taxon) + { + $taxon->setEnabled(false); + + $this->objectManager->persist($taxon); + $this->objectManager->flush(); + } + /** * @param string $name * diff --git a/src/Sylius/Behat/Context/Ui/Admin/ManagingTaxonsContext.php b/src/Sylius/Behat/Context/Ui/Admin/ManagingTaxonsContext.php index e63470a920..86921ee73e 100644 --- a/src/Sylius/Behat/Context/Ui/Admin/ManagingTaxonsContext.php +++ b/src/Sylius/Behat/Context/Ui/Admin/ManagingTaxonsContext.php @@ -422,6 +422,14 @@ final class ManagingTaxonsContext implements Context Assert::same($this->createPage->getFirstTaxonOnTheList(), $taxonName); } + /** + * @When /^I enable it$/ + */ + public function iEnableIt(): void + { + $this->updatePage->enable(); + } + /** * @When /^I disable it$/ */ @@ -431,7 +439,15 @@ final class ManagingTaxonsContext implements Context } /** - * @Then /^it should be marked as disabled$/ + * @Then /^(?:this taxon|it) should be marked as enabled/ + */ + public function itShouldBeMarkedAsEnabled(): void + { + Assert::true($this->updatePage->isEnabled()); + } + + /** + * @Then /^(?:this taxon|it) should be marked as disabled$/ */ public function itShouldBeMarkedAsDisabled(): void { diff --git a/src/Sylius/Behat/Page/Admin/Taxon/UpdatePage.php b/src/Sylius/Behat/Page/Admin/Taxon/UpdatePage.php index 0e3094057d..29f100e368 100644 --- a/src/Sylius/Behat/Page/Admin/Taxon/UpdatePage.php +++ b/src/Sylius/Behat/Page/Admin/Taxon/UpdatePage.php @@ -205,6 +205,11 @@ class UpdatePage extends BaseUpdatePage implements UpdatePageInterface }); } + public function enable(): void + { + $this->getElement('enabled')->check(); + } + public function disable(): void { $this->getElement('enabled')->uncheck(); diff --git a/src/Sylius/Behat/Page/Admin/Taxon/UpdatePageInterface.php b/src/Sylius/Behat/Page/Admin/Taxon/UpdatePageInterface.php index a026f8f65a..e2e35d8805 100644 --- a/src/Sylius/Behat/Page/Admin/Taxon/UpdatePageInterface.php +++ b/src/Sylius/Behat/Page/Admin/Taxon/UpdatePageInterface.php @@ -66,6 +66,8 @@ interface UpdatePageInterface extends BaseUpdatePageInterface public function activateLanguageTab(string $locale): void; + public function enable(): void; + public function disable(): void; public function isEnabled(): bool;