Improves managing taxons disable/enable feature

This commit is contained in:
Luca Gallinari 2020-03-30 11:55:15 +02:00 committed by Manuele Menozzi
parent acb183aa2d
commit 3bd9b1ce5c
5 changed files with 64 additions and 1 deletions

View file

@ -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

View file

@ -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
*

View file

@ -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
{

View file

@ -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();

View file

@ -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;