[Behat] Fixes after PR review

This commit is contained in:
Grzegorz Sadowski 2016-07-07 09:11:43 +02:00
parent 5c266bb160
commit 0c08ccd63a
7 changed files with 35 additions and 33 deletions

View file

@ -12,12 +12,11 @@ Feature: Viewing orders on my account page
And I am a logged in customer
And I placed an order "#00000666"
And I bought a single "Angel T-Shirt"
And I addressed it to "Lucifer Morningstar", "Seaside Fwy", "90802" "Los Angeles" in the "United States"
And for the billing address of "Mazikeen Lilim" in the "Pacific Coast Hwy", "90806" "Los Angeles", "United States"
And I addressed it to "Lucifer Morningstar", "Seaside Fwy", "90802" "Los Angeles" in the "United States" with identical billing address
And I chose "Free" shipping method with "Cash on Delivery" payment
And there is another customer "oliver@teamarrow.com" that placed an order "#00000999"
And the customer bought a single "Green Arrow"
And the customer "Oliver Queen" addressed it to "Seaside Fwy", "90802" "Los Angeles" in the "United States"
And the customer "Oliver Queen" addressed it to "Seaside Fwy", "90802" "Los Angeles" in the "United States" with identical billing address
@ui
Scenario: Viewing orders

View file

@ -13,8 +13,7 @@ Feature: Viewing details of an order
And I am a logged in customer
And I placed an order "#00000666"
And I bought an "Angel T-Shirt" and an "Angel Mug"
And I addressed it to "Lucifer Morningstar", "Seaside Fwy", "90802" "Los Angeles" in the "United States"
And for the billing address of "Mazikeen Lilim" in the "Pacific Coast Hwy", "90806" "Los Angeles", "United States"
And I addressed it to "Lucifer Morningstar", "Seaside Fwy", "90802" "Los Angeles" in the "United States" with identical billing address
And I chose "Free" shipping method with "Cash on Delivery" payment
@ui @javascript

View file

@ -12,8 +12,7 @@ Feature: Viewing only my orders on my account page
And I am a logged in customer
And I placed an order "#00000666"
And I bought a single "Angel T-Shirt"
And I addressed it to "Lucifer Morningstar", "Seaside Fwy", "90802" "Los Angeles" in the "United States"
And for the billing address of "Mazikeen Lilim" in the "Pacific Coast Hwy", "90806" "Los Angeles", "United States"
And I addressed it to "Lucifer Morningstar", "Seaside Fwy", "90802" "Los Angeles" in the "United States" with identical billing address
And I chose "Free" shipping method with "Cash on Delivery" payment
@ui

View file

@ -11,8 +11,7 @@ Feature: Finalizing order payment
And the store allows paying with "Cash on Delivery"
And there is a customer "lucy@teamlucifer.com" that placed an order "#00000666"
And the customer bought a single "Angel T-Shirt"
And the customer "Lucifer Morningstar" addressed it to "Seaside Fwy", "90802" "Los Angeles" in the "United States"
And for the billing address of "Mazikeen Lilim" in the "Pacific Coast Hwy", "90806" "Los Angeles", "United States"
And the customer "Lucifer Morningstar" addressed it to "Seaside Fwy", "90802" "Los Angeles" 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

View file

@ -11,8 +11,7 @@ Feature: Shipping an order
And the store allows paying with "Cash on Delivery"
And there is a customer "lucy@teamlucifer.com" that placed an order "#00000666"
And the customer bought a single "Angel T-Shirt"
And the customer "Lucifer Morningstar" addressed it to "Seaside Fwy", "90802" "Los Angeles" in the "United States"
And for the billing address of "Mazikeen Lilim" in the "Pacific Coast Hwy", "90806" "Los Angeles", "United States"
And the customer "Lucifer Morningstar" addressed it to "Seaside Fwy", "90802" "Los Angeles" 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

View file

@ -28,7 +28,6 @@ use Sylius\Component\Core\OrderProcessing\OrderShipmentProcessorInterface;
use Sylius\Component\Core\Repository\OrderRepositoryInterface;
use Sylius\Component\Core\Test\Services\SharedStorageInterface;
use Sylius\Component\Order\OrderTransitions;
use Sylius\Component\Payment\Factory\PaymentFactoryInterface;
use Sylius\Component\Payment\Model\PaymentInterface;
use Sylius\Component\Payment\Model\PaymentMethodInterface;
use Sylius\Component\Payment\PaymentTransitions;
@ -63,11 +62,6 @@ final class OrderContext implements Context
*/
private $orderShipmentFactory;
/**
* @var PaymentFactoryInterface
*/
private $paymentFactory;
/**
* @var FactoryInterface
*/
@ -103,7 +97,6 @@ final class OrderContext implements Context
* @param OrderRepositoryInterface $orderRepository
* @param FactoryInterface $orderFactory
* @param OrderShipmentProcessorInterface $orderShipmentFactory
* @param PaymentFactoryInterface $paymentFactory
* @param FactoryInterface $orderItemFactory
* @param OrderItemQuantityModifierInterface $itemQuantityModifier
* @param FactoryInterface $customerFactory
@ -116,7 +109,6 @@ final class OrderContext implements Context
OrderRepositoryInterface $orderRepository,
FactoryInterface $orderFactory,
OrderShipmentProcessorInterface $orderShipmentFactory,
PaymentFactoryInterface $paymentFactory,
FactoryInterface $orderItemFactory,
OrderItemQuantityModifierInterface $itemQuantityModifier,
FactoryInterface $customerFactory,
@ -128,7 +120,6 @@ final class OrderContext implements Context
$this->orderRepository = $orderRepository;
$this->orderFactory = $orderFactory;
$this->orderShipmentFactory = $orderShipmentFactory;
$this->paymentFactory = $paymentFactory;
$this->orderItemFactory = $orderItemFactory;
$this->itemQuantityModifier = $itemQuantityModifier;
$this->customerFactory = $customerFactory;
@ -188,11 +179,21 @@ final class OrderContext implements Context
$order->setBillingAddress($address);
$this->stateMachineFactory->get($order, OrderCheckoutTransitions::GRAPH)->apply(OrderCheckoutTransitions::TRANSITION_ADDRESS);
$this->applyTransitionOnOrderCheckout($order, OrderCheckoutTransitions::TRANSITION_ADDRESS);
$this->objectManager->flush();
}
/**
* @Given /^the customer ("[^"]+" addressed it to "[^"]+", "[^"]+" "[^"]+" in the "[^"]+") with identical billing address$/
* @Given /^I (addressed it to "[^"]+", "[^"]+", "[^"]+" "[^"]+" in the "[^"]+") with identical billing address$/
*/
public function theCustomerAddressedItToWithIdenticalBillingAddress(AddressInterface $address)
{
$this->theCustomerAddressedItTo($address);
$this->forTheBillingAddressOf($address);
}
/**
* @Given /^the customer chose ("[^"]+" shipping method) (to "[^"]+") with ("[^"]+" payment)$/
*/
@ -207,19 +208,18 @@ final class OrderContext implements Context
$order->setShippingAddress($address);
$order->setBillingAddress($address);
$this->stateMachineFactory->get($order, OrderCheckoutTransitions::GRAPH)->apply(OrderCheckoutTransitions::TRANSITION_ADDRESS);
$this->applyTransitionOnOrderCheckout($order, OrderCheckoutTransitions::TRANSITION_ADDRESS);
$this->orderShipmentFactory->processOrderShipment($order);
$order->getShipments()->first()->setMethod($shippingMethod);
$this->stateMachineFactory->get($order, OrderCheckoutTransitions::GRAPH)->apply(OrderCheckoutTransitions::TRANSITION_SELECT_SHIPPING);
$this->applyTransitionOnOrderCheckout($order, OrderCheckoutTransitions::TRANSITION_SELECT_SHIPPING);
$payment = $this->paymentFactory->createWithAmountAndCurrencyCode($order->getTotal(), $order->getCurrencyCode());
$payment = $order->getLastPayment();
$payment->setMethod($paymentMethod);
$order->addPayment($payment);
$this->stateMachineFactory->get($order, OrderCheckoutTransitions::GRAPH)->apply(OrderCheckoutTransitions::TRANSITION_SELECT_PAYMENT);
$this->stateMachineFactory->get($order, OrderCheckoutTransitions::GRAPH)->apply(OrderCheckoutTransitions::TRANSITION_COMPLETE);
$this->applyTransitionOnOrderCheckout($order, OrderCheckoutTransitions::TRANSITION_SELECT_PAYMENT);
$this->applyTransitionOnOrderCheckout($order, OrderCheckoutTransitions::TRANSITION_COMPLETE);
$this->objectManager->flush();
}
@ -238,14 +238,13 @@ final class OrderContext implements Context
$this->orderShipmentFactory->processOrderShipment($order);
$order->getShipments()->first()->setMethod($shippingMethod);
$this->stateMachineFactory->get($order, OrderCheckoutTransitions::GRAPH)->apply(OrderCheckoutTransitions::TRANSITION_SELECT_SHIPPING);
$this->applyTransitionOnOrderCheckout($order, OrderCheckoutTransitions::TRANSITION_SELECT_SHIPPING);
$payment = $this->paymentFactory->createWithAmountAndCurrencyCode($order->getTotal(), $order->getCurrencyCode());
$payment = $order->getLastPayment();
$payment->setMethod($paymentMethod);
$order->addPayment($payment);
$this->stateMachineFactory->get($order, OrderCheckoutTransitions::GRAPH)->apply(OrderCheckoutTransitions::TRANSITION_SELECT_PAYMENT);
$this->stateMachineFactory->get($order, OrderCheckoutTransitions::GRAPH)->apply(OrderCheckoutTransitions::TRANSITION_COMPLETE);
$this->applyTransitionOnOrderCheckout($order, OrderCheckoutTransitions::TRANSITION_SELECT_PAYMENT);
$this->applyTransitionOnOrderCheckout($order, OrderCheckoutTransitions::TRANSITION_COMPLETE);
$this->objectManager->flush();
}
@ -438,6 +437,15 @@ final class OrderContext implements Context
$this->stateMachineFactory->get($shipment, ShipmentTransitions::GRAPH)->apply($transition);
}
/**
* @param OrderInterface $order
* @param string $transition
*/
private function applyTransitionOnOrderCheckout(OrderInterface $order, $transition)
{
$this->stateMachineFactory->get($order, OrderCheckoutTransitions::GRAPH)->apply($transition);
}
/**
* @param ProductVariantInterface $productVariant
* @param int $price

View file

@ -62,7 +62,6 @@
<argument type="service" id="sylius.repository.order" container="symfony" />
<argument type="service" id="sylius.factory.order" container="symfony" />
<argument type="service" id="sylius.order_processing.shipment_processor" container="symfony" />
<argument type="service" id="sylius.factory.payment" container="symfony" />
<argument type="service" id="sylius.factory.order_item" container="symfony" />
<argument type="service" id="sylius.order_item_quantity_modifier" container="symfony" />
<argument type="service" id="sylius.factory.customer" container="symfony" />