Skip to content

Commit

Permalink
[CoreBundle] also add tests for new customer-deletion rule
Browse files Browse the repository at this point in the history
  • Loading branch information
dpfaffenbauer committed Mar 22, 2019
1 parent 7bd8560 commit 80f2193
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
27 changes: 27 additions & 0 deletions features/order/customer_deletion.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
@order @order_customer_deletion
Feature: Create a new order

Background:
Given the site operates on a store in "Austria"
And the site operates on locale "en"
And the site has a tax rate "AT" with "20%" rate
And the site has a tax rule group "AT"
And the tax rule group has a tax rule for country "Austria" with tax rate "AT"
And the site has a product "T-Shirt" priced at 2000
And the product has the tax rule group "AT"
And the site has a customer "some-customer@something.com"
And the customer "some-customer@something.com" has an address with country "Austria", "4600", "Wels", "Freiung", "9-11/N3"

And the cart belongs to customer "some-customer@something.com"

Scenario: Create a new order and delete the customer
Given I add the product "T-Shirt" to my cart
And the cart ships to customer "some-customer@something.com" address with postcode "4600"
And the cart invoices to customer "some-customer@something.com" address with postcode "4600"
And I create an order from my cart
Then It should throw an error deleting the customer "some-customer@something.com"

Scenario: Just delete an Customer Account
Given the site has a customer "some-other@something.com"
And the customer "some-other@something.com" has an address with country "Austria", "4600", "Wels", "Freiung", "9-11/N3"
Then It should not throw an error deleting the customer "some-other@something.com"
18 changes: 18 additions & 0 deletions src/CoreShop/Behat/Context/Domain/CustomerContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,22 @@ public function iShouldBeLoggedInWithEmail(CustomerInterface $customer)
)
);
}

/**
* @Then /^It should throw an error deleting the (customer "[^"]+")$/
*/
public function itShouldThrowAnErrorDeletingCustomer(CustomerInterface $customer)
{
Assert::throws(function() use ($customer) {
$customer->delete();
});
}

/**
* @Then /^It should not throw an error deleting the (customer "[^"]+")$/
*/
public function itShouldNotThrowAnErrorDeletingTheCustomer(CustomerInterface $customer)
{
$customer->delete();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ default:
- coreshop.behat.context.setup.shipping

- coreshop.behat.context.domain.order
- coreshop.behat.context.domain.customer
- coreshop.behat.context.domain.notification_rule
filters:
tags: "@order"

0 comments on commit 80f2193

Please sign in to comment.