[API][Tax rate] Implement deleting_tax_rate feature

This commit is contained in:
hatem20 2020-10-01 00:20:04 +02:00 committed by Jakub Tobiasz
parent f84fce7dc9
commit c8fe3b325f
No known key found for this signature in database
GPG key ID: 6434250CB3525233
3 changed files with 37 additions and 1 deletions

View file

@ -10,7 +10,7 @@ Feature: Deleting a tax rate
And the store has "United States Sales Tax" tax rate of 20% for "Sports gear" within the "US" zone
And I am logged in as an administrator
@ui
@ui @api
Scenario: Deleted tax rate should disappear from the registry
When I delete tax rate "United States Sales Tax"
Then I should be notified that it has been successfully deleted

View file

@ -150,4 +150,36 @@ class ManagingTaxRateContext implements Context
sprintf('Tax rate does is not included in price')
);
}
/**
* @When I delete tax rate :taxRate
*/
public function iDeleteTaxRate(TaxRateInterface $taxRate): void
{
$this->client->delete((string) $taxRate->getId());
}
/**
* @Then I should be notified that it has been successfully deleted
*/
public function iShouldBeNotifiedThatItHasBeenSuccessfullyDeleted(): void
{
Assert::true(
$this->responseChecker->isDeletionSuccessful($this->client->getLastResponse()),
'Tax rate could not be deleted'
);
}
/**
* @Then /^(this tax rate) should no longer exist in the registry$/
*/
public function thisTaxRateShouldNoLongerExistInTheRegistry(TaxRateInterface $taxRate): void
{
$name = $taxRate->getName();
Assert::false(
$this->responseChecker->hasItemWithValue($this->client->index(), 'name', $name),
sprintf('Tax rate with name %s exists', $name)
);
}
}

View file

@ -36,6 +36,10 @@
<itemOperation name="admin_get">
<attribute name="method">GET</attribute>
</itemOperation>
<itemOperation name="admin_delete">
<attribute name="method">DELETE</attribute>
</itemOperation>
</itemOperations>
</resource>
</resources>