Skip to content

Commit

Permalink
[Admin][Order] Implement scenarios for modifying a customer's shippin…
Browse files Browse the repository at this point in the history
…g address on an order
  • Loading branch information
GSadee committed Sep 13, 2016
1 parent 80bf390 commit 0f86e10
Show file tree
Hide file tree
Showing 21 changed files with 422 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Feature: Modifying a customer shipping address after an order has been placed
And the customer chose "Free" shipping method with "Cash on Delivery" payment
And I am logged in as an administrator

@todo
@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
Expand All @@ -30,7 +30,7 @@ Feature: Modifying a customer shipping address after an order has been placed
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"

@todo
@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"
Expand All @@ -41,7 +41,7 @@ Feature: Modifying a customer shipping address after an order has been placed
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"

@todo
@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"
Expand All @@ -52,7 +52,7 @@ Feature: Modifying a customer shipping address after an order has been placed
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"

@todo
@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"
Expand All @@ -63,7 +63,7 @@ Feature: Modifying a customer shipping address after an order has been placed
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"

@todo
@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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Feature: Modifying a customer's shipping address on an order with an applied cou
And the customer chose "Free" shipping method with "Cash on Delivery" payment
And I am logged in as an administrator

@todo
@ui
Scenario: Modifying a customer's shipping address when the applied coupon is no longer valid
Given the coupon "HOLIDAY" was used
When I view the summary of the order "#00000001"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Feature: Modifying a customer's shipping address of an order with a different cu
And the customer chose "DHL" shipping method with "Cash on Delivery" payment
And I am logged in as an administrator

@todo
@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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Feature: Modifying a customer's shipping address on an order with an applied pro
And the customer chose "Free" shipping method with "Cash on Delivery" payment
And I am logged in as an administrator

@todo
@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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Feature: Modifying a customer's shipping address on an order with taxes
And the customer chose "Free" shipping method with "Offline" payment
And I am logged in as an administrator

@todo
@ui
Scenario: Modifying a customer's shipping address when the applied promotion is no longer valid
Given the "VAT" tax rate is of 10%
When I view the summary of the order "#00000001"
Expand Down
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$/
*/
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) is of ([^"]+)%$/
*/
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 0f86e10

Please sign in to comment.