Skip to content

Commit

Permalink
Merge pull request #6062 from GSadee/modifying-shipping-address
Browse files Browse the repository at this point in the history
[Admin][Order] Modifying a customer's shipping address on an order
  • Loading branch information
michalmarcinkowski committed Sep 15, 2016
2 parents b52cef7 + fd8eb16 commit 399c6b4
Show file tree
Hide file tree
Showing 28 changed files with 687 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ Feature: Verifying inventory quantity on cart summary
Scenario: Being unable to save a cart with product that is out of stock
Given I have added 3 products "Iron Maiden T-Shirt" in the cart
When I change "Iron Maiden T-Shirt" quantity to 6
And I save my changes
And I update my cart
Then I should be notified that this product cannot be updated

@ui
Scenario: Placing an order with products that have sufficient quantity
Given I have added 3 products "Iron Maiden T-Shirt" in the cart
When I change "Iron Maiden T-Shirt" quantity to 5
And I save my changes
And I update my cart
Then I should not be notified that this product cannot be updated
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
@modifying_shipping_address
Feature: Modifying a customer shipping address after an order has been placed
In order to ship an order to a correct place
As an Administrator
I want to be able to modify a customer's shipping address after an order has been placed

Background:
Given the store operates on a single channel in the "United States" named "Web"
And the store ships everywhere for free
And the store allows paying with "Cash on Delivery"
And the store has a product "Suit" priced at "$400.00"
And there is a customer "mike@ross.com" that placed an order "#00000001"
And the customer bought a single "Suit"
And the customer "Mike Ross" addressed it to "350 5th Ave", "10118" "New York" in the "United States" with identical billing address
And the customer chose "Free" shipping method with "Cash on Delivery" payment
And I am logged in as an administrator

@ui
Scenario: Modifying a customer's shipping address
When I view the summary of the order "#00000001"
And I want to modify a customer's shipping address of this order
And I specify the first name as "Lucifer"
And I specify the last name as "Morningstar"
And I specify the street as "Seaside Fwy"
And I choose "United States" as the country
And I specify the city as "Los Angeles"
And I specify the postcode as "90802"
And I save my changes
Then I should be notified that it has been successfully edited
And this order should be shipped to "Lucifer Morningstar", "Seaside Fwy", "90802", "Los Angeles", "United States"

@ui
Scenario: Modifying a customer's shipping address when a product's price has been changed
Given the product "Suit" changed its price to "$300.00"
When I view the summary of the order "#00000001"
And I want to modify a customer's shipping address of this order
And I specify their shipping address as "Los Angeles", "Seaside Fwy", "90802", "United States" for "Lucifer Morningstar"
And I save my changes
Then I should be notified that it has been successfully edited
And this order should be shipped to "Lucifer Morningstar", "Seaside Fwy", "90802", "Los Angeles", "United States"
And the order's total should still be "$400.00"

@ui
Scenario: Modifying a customer's shipping address when a channel has been disabled
Given the channel "Web" has been disabled
When I view the summary of the order "#00000001"
And I want to modify a customer's shipping address of this order
And I specify their shipping address as "Los Angeles", "Seaside Fwy", "90802", "United States" for "Lucifer Morningstar"
And I save my changes
Then I should be notified that it has been successfully edited
And this order should be shipped to "Lucifer Morningstar", "Seaside Fwy", "90802", "Los Angeles", "United States"
And the order's total should still be "$400.00"

@ui
Scenario: Modifying a customer's shipping address when the currency has been disabled
Given the currency "USD" has been disabled
When I view the summary of the order "#00000001"
And I want to modify a customer's shipping address of this order
And I specify their shipping address as "Los Angeles", "Seaside Fwy", "90802", "United States" for "Lucifer Morningstar"
And I save my changes
Then I should be notified that it has been successfully edited
And this order should be shipped to "Lucifer Morningstar", "Seaside Fwy", "90802", "Los Angeles", "United States"
And the order's total should still be "$400.00"

@ui
Scenario: Modifying a customer's shipping address when the product is out of stock
Given the product "Suit" is out of stock
When I view the summary of the order "#00000001"
And I want to modify a customer's shipping address of this order
And I specify their shipping address as "Los Angeles", "Seaside Fwy", "90802", "United States" for "Lucifer Morningstar"
And I save my changes
Then I should be notified that it has been successfully edited
And this order should be shipped to "Lucifer Morningstar", "Seaside Fwy", "90802", "Los Angeles", "United States"
And the order's total should still be "$400.00"
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
@modifying_shipping_address
Feature: Modifying a customer's shipping address on an order with an applied coupon
In order to ship an order to a correct place
As an Administrator
I want to be able to modify a customer's shipping address without changing an order's total

Background:
Given the store operates on a single channel in "United States"
And the store ships everywhere for free
And the store allows paying with "Cash on Delivery"
And the store classifies its products as "Suits"
And the store has a product "Suit" priced at "$400.00"
And it belongs to "Suits"
And the store has a promotion "Holiday promotion" with a coupon "HOLIDAY" that is limited to "10" usages
And the promotion gives "$50.00" off if order contains products classified as "Suits"
And there is a customer "mike@ross.com" that placed an order "#00000001"
And the customer bought a single "Suit" using "HOLIDAY" coupon
And the customer "Mike Ross" addressed it to "350 5th Ave", "10118" "New York" in the "United States" with identical billing address
And the customer chose "Free" shipping method with "Cash on Delivery" payment
And I am logged in as an administrator

@ui
Scenario: Modifying a customer's shipping address when the applied coupon is no longer valid
Given the coupon "HOLIDAY" was used up to its usage limit
When I view the summary of the order "#00000001"
And I want to modify a customer's shipping address of this order
And I specify their shipping address as "Los Angeles", "Seaside Fwy", "90802", "United States" for "Lucifer Morningstar"
And I save my changes
Then I should be notified that it has been successfully edited
And this order should be shipped to "Lucifer Morningstar", "Seaside Fwy", "90802", "Los Angeles", "United States"
And the order's total should still be "$350.00"
And the order's promotion total should still be "-$50.00"
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
@modifying_shipping_address
Feature: Modifying a customer's shipping address of an order with a different currency
In order to ship an order to a correct place
As an Administrator
I want to be able to modify a customer's shipping address without changing an order's total

Background:
Given the store operates on a channel named "Web"
And the store ships to "United States"
And the store has a zone "English" with code "EN"
And this zone has the "United States" country member
And that channel allows to shop using the "USD" currency
And that channel allows to shop using the "GBP" currency with exchange rate 3.0
And that channel uses the "USD" currency by default
And the store allows paying with "Cash on Delivery"
And the store has "DHL" shipping method with "$20.00" fee within the "EN" zone
And the store has a product "Suit" priced at "$400.00"
And there is a customer "mike@ross.com" that placed an order "#00000001"
And the customer has chosen to order in the "GBP" currency
And the customer bought a single "Suit"
And the customer "Mike Ross" addressed it to "350 5th Ave", "10118" "New York" in the "United States" with identical billing address
And the customer chose "DHL" shipping method with "Cash on Delivery" payment
And I am logged in as an administrator

@ui
Scenario: Modifying a customer's shipping address when the exchange rate has been changed
Given the exchange rate for currency "GBP" was changed to 2.00
When I view the summary of the order "#00000001"
And I want to modify a customer's shipping address of this order
And I specify their shipping address as "Los Angeles", "Seaside Fwy", "90802", "United States" for "Lucifer Morningstar"
And I save my changes
Then I should be notified that it has been successfully edited
And this order should be shipped to "Lucifer Morningstar", "Seaside Fwy", "90802", "Los Angeles", "United States"
And the order's total should still be "£1,260.00"
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
@modifying_shipping_address
Feature: Modifying a customer's shipping address on an order with an applied promotion
In order to ship an order to a correct place
As an Administrator
I want to be able to modify a customer's shipping address without changing an order's total

Background:
Given the store operates on a single channel in the "United States" named "Web"
And the store ships everywhere for free
And the store allows paying with "Cash on Delivery"
And the store classifies its products as "Suits"
And the store has a product "Suit" priced at "$400.00"
And it belongs to "Suits"
And there is a promotion "Holiday promotion"
And the promotion gives "$50.00" off if order contains products classified as "Suits"
And there is a customer "mike@ross.com" that placed an order "#00000001"
And the customer bought a single "Suit"
And the customer "Mike Ross" addressed it to "350 5th Ave", "10118" "New York" in the "United States" with identical billing address
And the customer chose "Free" shipping method with "Cash on Delivery" payment
And I am logged in as an administrator

@ui
Scenario: Modifying a customer's shipping address when the applied promotion is no longer valid
Given the promotion was disabled for the channel "Web"
When I view the summary of the order "#00000001"
And I want to modify a customer's shipping address of this order
And I specify their shipping address as "Los Angeles", "Seaside Fwy", "90802", "United States" for "Lucifer Morningstar"
And I save my changes
Then I should be notified that it has been successfully edited
And this order should be shipped to "Lucifer Morningstar", "Seaside Fwy", "90802", "Los Angeles", "United States"
And the order's total should still be "$350.00"
And the order's promotion total should still be "-$50.00"
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
@modifying_shipping_address
Feature: Modifying a customer's shipping address on an order with taxes
In order to ship an order to a correct place
As an Administrator
I want to be able to modify a customer's shipping address without changing the order's total

Background:
Given the store operates on a single channel in "United States"
And the store ships everything for free within the "US" zone
And the store allows paying offline
And the store has "VAT" tax rate of 20% for "Suits" within the "US" zone
And the store has a product "Suit" priced at "$400.00"
And it belongs to "Suits" tax category
And there is a customer "mike@ross.com" that placed an order "#00000001"
And the customer bought a single "Suit"
And the customer "Mike Ross" addressed it to "350 5th Ave", "10118" "New York" in the "United States" with identical billing address
And the customer chose "Free" shipping method with "Offline" payment
And I am logged in as an administrator

@ui
Scenario: Modifying a customer's shipping address when the applied promotion is no longer valid
Given the "VAT" tax rate has changed to 10%
When I view the summary of the order "#00000001"
And I want to modify a customer's shipping address of this order
And I specify their shipping address as "Los Angeles", "Seaside Fwy", "90802", "United States" for "Lucifer Morningstar"
And I save my changes
Then I should be notified that it has been successfully edited
And this order should be shipped to "Lucifer Morningstar", "Seaside Fwy", "90802", "Los Angeles", "United States"
And the order's total should still be "$480.00"
And the order's tax total should still be "$80.00"
12 changes: 12 additions & 0 deletions src/Sylius/Behat/Context/Setup/ChannelContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,17 @@ public function storeOperatesOnASingleChannelInUnitedStates()
$this->sharedStorage->set('channel', $defaultData['channel']);
}

/**
* @Given the store operates on a single channel in the "United States" named :channelIdentifier
*/
public function storeOperatesOnASingleChannelInTheUnitedStatesNamed($channelIdentifier)
{
$defaultData = $this->unitedStatesChannelFactory->create($channelIdentifier, $channelIdentifier);

$this->sharedStorage->setClipboard($defaultData);
$this->sharedStorage->set('channel', $defaultData['channel']);
}

/**
* @Given the store operates on a single channel
*/
Expand Down Expand Up @@ -125,6 +136,7 @@ public function theChannelIsEnabled(ChannelInterface $channel)

/**
* @Given the channel :channel is disabled
* @Given the channel :channel has been disabled
*/
public function theChannelIsDisabled(ChannelInterface $channel)
{
Expand Down
1 change: 1 addition & 0 deletions src/Sylius/Behat/Context/Setup/CurrencyContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ public function theStoreHasCurrencyAnd($currencyCode, $secondCurrencyCode)
* @Given the store has disabled currency :currencyCode
* @Given the currency :currencyCode is disabled (as well)
* @Given the currency :currencyCode gets disabled
* @Given the currency :currencyCode has been disabled
*/
public function theStoreHasDisabledCurrency($currencyCode)
{
Expand Down
10 changes: 10 additions & 0 deletions src/Sylius/Behat/Context/Setup/ProductContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,16 @@ public function theProductVariantIsTrackedByTheInventory(ProductVariantInterface
$this->objectManager->flush();
}

/**
* @Given /^the (product "[^"]+") changed its price to ("[^"]+")$/
*/
public function theProductChangedItsPriceTo(ProductInterface $product, $price)
{
$product->getFirstVariant()->setPrice($price);

$this->objectManager->flush();
}

/**
* @param string $type
* @param string $name
Expand Down
25 changes: 24 additions & 1 deletion src/Sylius/Behat/Context/Setup/PromotionContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Doctrine\Common\Persistence\ObjectManager;
use Sylius\Component\Core\Factory\ActionFactoryInterface;
use Sylius\Component\Core\Factory\RuleFactoryInterface;
use Sylius\Component\Core\Model\ChannelInterface;
use Sylius\Component\Core\Model\PromotionInterface;
use Sylius\Component\Core\Model\TaxonInterface;
use Sylius\Component\Core\Test\Factory\TestPromotionFactoryInterface;
Expand Down Expand Up @@ -113,12 +114,14 @@ public function thereIsPromotion($promotionName, $promotionCode = null)
/**
* @Given the store has promotion :promotionName with coupon :couponCode
* @Given the store has also promotion :promotionName with coupon :couponCode
* @Given the store has a promotion :promotionName with a coupon :couponCode that is limited to :usageLimit usages
*/
public function thereIsPromotionWithCoupon($promotionName, $couponCode)
public function thereIsPromotionWithCoupon($promotionName, $couponCode, $usageLimit = null)
{
/** @var CouponInterface $coupon */
$coupon = $this->couponFactory->createNew();
$coupon->setCode($couponCode);
$coupon->setUsageLimit($usageLimit);

$promotion = $this->testPromotionFactory
->createForChannel($promotionName, $this->sharedStorage->get('channel'))
Expand Down Expand Up @@ -441,6 +444,26 @@ public function itIsCouponBasedPromotion(PromotionInterface $promotion)
$this->objectManager->flush();
}

/**
* @Given /^(the promotion) was disabled for the (channel "[^"]+")$/
*/
public function thePromotionWasDisabledForTheChannel(PromotionInterface $promotion, ChannelInterface $channel)
{
$promotion->removeChannel($channel);

$this->objectManager->flush();
}

/**
* @Given /^the (coupon "[^"]+") was used up to its usage limit$/
*/
public function theCouponWasUsed(CouponInterface $coupon)
{
$coupon->setUsed($coupon->getUsageLimit());

$this->objectManager->flush();
}

/**
* @param array $taxonCodes
*
Expand Down
21 changes: 20 additions & 1 deletion src/Sylius/Behat/Context/Setup/TaxationContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Sylius\Behat\Context\Setup;

use Behat\Behat\Context\Context;
use Doctrine\Common\Persistence\ObjectManager;
use Sylius\Component\Addressing\Model\ZoneInterface;
use Sylius\Component\Addressing\Repository\ZoneRepositoryInterface;
use Sylius\Component\Core\Formatter\StringInflector;
Expand Down Expand Up @@ -57,28 +58,36 @@ final class TaxationContext implements Context
*/
private $zoneRepository;

/**
* @var ObjectManager
*/
private $objectManager;

/**
* @param SharedStorageInterface $sharedStorage
* @param FactoryInterface $taxRateFactory
* @param FactoryInterface $taxCategoryFactory
* @param RepositoryInterface $taxRateRepository
* @param TaxCategoryRepositoryInterface $taxCategoryRepository
* @param ZoneRepositoryInterface $zoneRepository
* @param ObjectManager $objectManager
*/
public function __construct(
SharedStorageInterface $sharedStorage,
FactoryInterface $taxRateFactory,
FactoryInterface $taxCategoryFactory,
RepositoryInterface $taxRateRepository,
TaxCategoryRepositoryInterface $taxCategoryRepository,
ZoneRepositoryInterface $zoneRepository
ZoneRepositoryInterface $zoneRepository,
ObjectManager $objectManager
) {
$this->sharedStorage = $sharedStorage;
$this->taxRateFactory = $taxRateFactory;
$this->taxCategoryFactory = $taxCategoryFactory;
$this->taxRateRepository = $taxRateRepository;
$this->taxCategoryRepository = $taxCategoryRepository;
$this->zoneRepository = $zoneRepository;
$this->objectManager = $objectManager;
}

/**
Expand Down Expand Up @@ -147,6 +156,16 @@ public function theStoreDoesNotHaveAnyCategoriesDefined()
}
}

/**
* @Given /^the ("[^"]+" tax rate) has changed to ([^"]+)%$/
*/
public function theTaxRateIsOfAmount(TaxRateInterface $taxRate, $amount)
{
$taxRate->setAmount($this->getAmountFromString($amount));

$this->objectManager->flush();
}

/**
* @param string $taxCategoryName
*
Expand Down
1 change: 1 addition & 0 deletions src/Sylius/Behat/Context/Transform/TaxRateContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public function __construct(RepositoryInterface $taxRateRepository)

/**
* @Transform :taxRate
* @Transform /^"([^"]+)" tax rate$/
*/
public function getTaxRateByName($taxRateName)
{
Expand Down
Loading

0 comments on commit 399c6b4

Please sign in to comment.