Skip to content

Commit

Permalink
[API][Tax rate] Implement deleting_tax_rate feature
Browse files Browse the repository at this point in the history
  • Loading branch information
hatem20 authored and jakubtobiasz committed Feb 15, 2023
1 parent f84fce7 commit c8fe3b3
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 32 additions & 0 deletions src/Sylius/Behat/Context/Api/Admin/ManagingTaxRateContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,36 @@ public function theTaxRateShouldIncludePrice(TaxRateInterface $taxRate): void
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)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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>

0 comments on commit c8fe3b3

Please sign in to comment.