deleting zone

This commit is contained in:
Olivier ALLAIN 2020-04-19 22:45:23 +02:00 committed by Grzegorz Sadowski
parent 3ddbcbf90b
commit e2c514f4be
No known key found for this signature in database
GPG key ID: EF87FF4E6E3BD364
4 changed files with 47 additions and 3 deletions

View file

@ -11,13 +11,13 @@ Feature: Deleting a zone
And the store has "Sales Tax" tax rate of 20% for "Sports gear" within the "SA" zone And the store has "Sales Tax" tax rate of 20% for "Sports gear" within the "SA" zone
And I am logged in as an administrator And I am logged in as an administrator
@ui @ui @api
Scenario: Deleted zone should disappear from the registry Scenario: Deleted zone should disappear from the registry
When I delete zone named "North America" When I delete zone named "North America"
Then I should be notified that it has been successfully deleted Then I should be notified that it has been successfully deleted
And the zone named "North America" should no longer exist in the registry And the zone named "North America" should no longer exist in the registry
@ui @ui @api
Scenario: Deleting zone with associated tax rates should not be possible Scenario: Deleting zone with associated tax rates should not be possible
When I delete zone named "South America" When I delete zone named "South America"
Then I should be notified that this zone cannot be deleted Then I should be notified that this zone cannot be deleted

View file

@ -116,6 +116,14 @@ final class ManagingZonesContext implements Context
$this->client->index(); $this->client->index();
} }
/**
* @When I delete zone named :zoneName
*/
public function iDeleteZoneNamed(ZoneInterface $zoneName): void
{
$this->client->delete($zoneName->getCode());
}
/** /**
* @Then I should be notified that it has been successfully created * @Then I should be notified that it has been successfully created
*/ */
@ -184,12 +192,46 @@ final class ManagingZonesContext implements Context
/** /**
* @Then I should see the zone named :name in the list * @Then I should see the zone named :name in the list
* @Then I should still see the zone named :name in the list
*/ */
public function iShouldSeeTheZoneNamedInTheList(string $name): void public function iShouldSeeTheZoneNamedInTheList(string $name): void
{ {
Assert::true( Assert::true(
$this->responseChecker->hasItemWithValue($this->client->getLastResponse(), 'name', $name), $this->responseChecker->hasItemWithValue($this->client->index(), 'name', $name),
sprintf('There is no zone with name "%s"', $name) sprintf('There is no zone with name "%s"', $name)
); );
} }
/**
* @Then I should be notified that it has been successfully deleted
*/
public function iShouldBeNotifiedThatItHasBeenSuccessfullyDeleted(): void
{
Assert::true($this->responseChecker->isDeletionSuccessful(
$this->client->getLastResponse()),
'Zone could not be deleted'
);
}
/**
* @Then the zone named :name should no longer exist in the registry
*/
public function theZoneNamedShouldNoLongerExistInTheRegistry(string $name): void
{
Assert::false(
$this->responseChecker->hasItemWithValue($this->client->index(), 'name', $name),
sprintf('Zone with name %s exist', $name)
);
}
/**
* @Then I should be notified that this zone cannot be deleted
*/
public function iShouldBeNotifiedThatThisZoneCannotBeDeleted(): void
{
Assert::false(
$this->responseChecker->isDeletionSuccessful($this->client->getLastResponse()),
'Zone can be deleted, but it should not'
);
}
} }

View file

@ -15,6 +15,7 @@ default:
- sylius.behat.context.setup.admin_api_security - sylius.behat.context.setup.admin_api_security
- sylius.behat.context.setup.geographical - sylius.behat.context.setup.geographical
- sylius.behat.context.setup.taxation
- sylius.behat.context.setup.zone - sylius.behat.context.setup.zone
- sylius.behat.context.api.admin.managing_zones - sylius.behat.context.api.admin.managing_zones

View file

@ -46,6 +46,7 @@
<attribute name="groups">zone:update</attribute> <attribute name="groups">zone:update</attribute>
</attribute> </attribute>
</itemOperation> </itemOperation>
<itemOperation name="delete" />
</itemOperations> </itemOperations>
<property name="id" identifier="false" writable="false" /> <property name="id" identifier="false" writable="false" />