Merge pull request #5956 from Arminek/rework-order-checkout-states

[Checkout] Be able to modify all past steps of the checkout
This commit is contained in:
Michał Marcinkowski 2016-09-08 10:26:23 +02:00 committed by GitHub
commit 7c5af249a7
21 changed files with 190 additions and 362 deletions

View file

@ -0,0 +1,104 @@
@checkout
Feature: Changing checkout steps
In order to have possibility to change remaining steps
As a Customer
I want to be able to modify these steps
Background:
Given the store operates on a single channel in "United States"
And the store has a product "PHP T-Shirt" priced at "$19.99"
And the store ships everywhere for free
And the store has "Raven Post" shipping method with "$10.00" fee
And the store allows paying offline
And the store allows paying "PayPal Express Checkout"
And I am a logged in customer
@ui
Scenario: Placing an order after moving back from the checkout summary to the addressing step but without any address modification
Given I had product "PHP T-Shirt" in the cart
And I was at the checkout summary step
When I go back to addressing step of the checkout
But I do not modify anything
And I return to the checkout summary step
And I confirm my order
Then I should see the thank you page
@ui
Scenario: Placing an order after moving back from the checkout summary to the shipping method step but without any shipping method modification
Given I had product "PHP T-Shirt" in the cart
And I was at the checkout summary step
When I go back to shipping step of the checkout
But I do not modify anything
And I return to the checkout summary step
And I confirm my order
Then I should see the thank you page
@ui
Scenario: Placing an order after moving back from the checkout summary to the payment method step but without any payment method modification
Given I had product "PHP T-Shirt" in the cart
And I was at the checkout summary step
When I go back to payment step of the checkout
But I do not modify anything
And I return to the checkout summary step
And I confirm my order
Then I should see the thank you page
@ui
Scenario: Changing address of my order
Given I had product "PHP T-Shirt" in the cart
And I specified the shipping address as "Ankh Morpork", "Frost Alley", "90210", "United States" for "Jon Snow"
When I go back to addressing step of the checkout
And I change the shipping address to "Ankh Morpork", "Fire Alley", "90350", "United States" for "Jon Snow"
And I complete the addressing step
Then I should be on the checkout shipping step
@ui
Scenario: Addressing my order after selecting payment method
Given I had product "PHP T-Shirt" in the cart
And I specified the shipping address as "Ankh Morpork", "Frost Alley", "90210", "United States" for "Jon Snow"
And I have proceeded order with "Free" shipping method and "Offline" payment
When I go back to addressing step of the checkout
And I change the shipping address to "Ankh Morpork", "Fire Alley", "90350", "United States" for "Jon Snow"
And I complete the addressing step
Then I should be on the checkout shipping step
@ui
Scenario: Addressing my order after selecting shipping method
Given I had product "PHP T-Shirt" in the cart
And I specified the shipping address as "Ankh Morpork", "Frost Alley", "90210", "United States" for "Jon Snow"
And I have proceeded selecting "Free" shipping method
When I go back to addressing step of the checkout
And I change the shipping address to "Ankh Morpork", "Fire Alley", "90350", "United States" for "Jon Snow"
And I complete the addressing step
Then I should be on the checkout shipping step
@ui
Scenario: Changing shipping method of my order
Given I had product "PHP T-Shirt" in the cart
And I specified the shipping address as "Ankh Morpork", "Frost Alley", "90210", "United States" for "Jon Snow"
And I have proceeded selecting "Free" shipping method
When I go back to shipping step of the checkout
And I select "Raven Post" shipping method
And I complete the shipping step
Then I should be on the checkout payment step
@ui
Scenario: Selecting shipping method after selecting payment method
Given I had product "PHP T-Shirt" in the cart
And I specified the shipping address as "Ankh Morpork", "Frost Alley", "90210", "United States" for "Jon Snow"
And I have proceeded order with "Free" shipping method and "Offline" payment
When I go back to shipping step of the checkout
And I select "Raven Post" shipping method
And I complete the shipping step
Then I should be on the checkout payment step
@ui
Scenario: Selecting payment method after complete checkout
Given I had product "PHP T-Shirt" in the cart
And I specified the shipping address as "Ankh Morpork", "Frost Alley", "90210", "United States" for "Jon Snow"
And I have proceeded order with "Free" shipping method and "Offline" payment
When I go back to payment step of the checkout
And I select "PayPal Express Checkout" payment method
And I complete the payment step
Then I should be on the checkout summary step

View file

@ -11,7 +11,7 @@ Feature: Returning from payment step to one of previous steps
And the store allows paying with "Paypal Express Checkout"
And I am a logged in customer
@ui @javascript
@ui
Scenario: Going back to shipping step with button
Given I have product "Hulk Mug" in the cart
And I specified the shipping address as "Ankh Morpork", "Frost Alley", "90210", "United States" for "Jon Snow"
@ -20,7 +20,7 @@ Feature: Returning from payment step to one of previous steps
Then I should be redirected to the shipping step
And I should be able to go to the payment step again
@ui @javascript
@ui
Scenario: Going back to shipping step with steps panel
Given I have product "Hulk Mug" in the cart
And I specified the shipping address as "Ankh Morpork", "Frost Alley", "90210", "United States" for "Jon Snow"
@ -29,7 +29,7 @@ Feature: Returning from payment step to one of previous steps
Then I should be redirected to the shipping step
And I should be able to go to the payment step again
@ui @javascript
@ui
Scenario: Going back to addressing step with steps panel
Given I have product "Hulk Mug" in the cart
And I specified the shipping address as "Ankh Morpork", "Frost Alley", "90210", "United States" for "Jon Snow"

View file

@ -27,7 +27,7 @@ Feature: Prices get updated when exchange rate changes during the whole checkout
And I specified the shipping address as "Ankh Morpork", "Frost Alley", "90210", "United States" for "Jon Snow"
Then the subtotal of "The Pug Mug" item should be "£50.00"
@ui @javascript
@ui
Scenario: Prices get updated on readdressing
Given I specified the shipping address as "Ankh Morpork", "Frost Alley", "90210", "United States" for "Jon Snow"
When the exchange rate for currency "GBP" was changed to 3.00
@ -42,7 +42,7 @@ Feature: Prices get updated when exchange rate changes during the whole checkout
And I complete the shipping step
Then the subtotal of "The Pug Mug" item should be "£20.00"
@ui @javascript
@ui
Scenario: Prices get updated on re-selecting shipping step
Given I specified the shipping address as "Ankh Morpork", "Frost Alley", "90210", "United States" for "Jon Snow"
And I have selected "Pigeon Mail" shipping method
@ -62,7 +62,7 @@ Feature: Prices get updated when exchange rate changes during the whole checkout
Then the "The Pug Mug" product should have unit price "£20.00"
And my order shipping should be "£10.00"
@ui @javascript
@ui
Scenario: Prices get updated on re-selecting payment method step
Given I specified the shipping address as "Ankh Morpork", "Frost Alley", "90210", "United States" for "Jon Snow"
And I proceed order with "Pigeon Mail" shipping method and "Offline" payment

View file

@ -11,7 +11,7 @@ Feature: Returning from order summary page to one of previous steps
And the store allows paying with "Cash on Delivery"
And I am a logged in customer
@ui @javascript
@ui
Scenario: Going back to payment step
Given I have product "Stark Robe" in the cart
And I specified the shipping address as "Ankh Morpork", "Frost Alley", "90210", "United States" for "Jon Snow"
@ -20,7 +20,7 @@ Feature: Returning from order summary page to one of previous steps
Then I should be redirected to the payment step
And I should be able to go to the summary page again
@ui @javascript
@ui
Scenario: Going back to shipping step with steps panel
Given I have product "Stark Robe" in the cart
And I specified the shipping address as "Ankh Morpork", "Frost Alley", "90210", "United States" for "Jon Snow"
@ -29,7 +29,7 @@ Feature: Returning from order summary page to one of previous steps
Then I should be redirected to the shipping step
And I should be able to go to the payment step again
@ui @javascript
@ui
Scenario: Going back to addressing step with steps panel
Given I have product "Stark Robe" in the cart
And I specified the shipping address as "Ankh Morpork", "Frost Alley", "90210", "United States" for "Jon Snow"

View file

@ -10,7 +10,7 @@ Feature: Returning from shipping step to addressing step
And the store ships everywhere for free
And I am a logged in customer
@ui @javascript
@ui
Scenario: Going back to addressing step with button
Given I have product "Apollo 11 T-Shirt" in the cart
And I specified the shipping address as "Ankh Morpork", "Frost Alley", "90210", "United States" for "Jon Snow"
@ -18,7 +18,7 @@ Feature: Returning from shipping step to addressing step
Then I should be redirected to the addressing step
And I should be able to go to the shipping step again
@ui @javascript
@ui
Scenario: Going back to the addressing step with steps panel
Given I have product "Apollo 11 T-Shirt" in the cart
And I specified the shipping address as "Ankh Morpork", "Frost Alley", "90210", "United States" for "Jon Snow"

View file

@ -21,7 +21,7 @@ Feature: Reapplying promotion on cart change
And there should be no shipping fee
And there should be no discount
@ui @javascript
@ui
Scenario: Receiving discount on shipping after shipping method change
Given the store has "DHL" shipping method with "$10.00" fee
And the store has "FedEx" shipping method with "$30.00" fee

View file

@ -18,7 +18,7 @@ Feature: Apply correct shipping fee on order
Then my cart total should be "$110.00"
And my cart shipping total should be "$10.00"
@ui @javascript
@ui
Scenario: Changing shipping fee after shipping method change
Given I have product "PHP T-Shirt" in the cart
And I chose "DHL" shipping method

View file

@ -57,7 +57,7 @@ final class AddressingContext implements Context
/**
* @Transform /^address as "([^"]+)", "([^"]+)", "([^"]+)", "([^"]+)" for "([^"]+)"$/
* @Transform /^address is "([^"]+)", "([^"]+)", "([^"]+)", "([^"]+)" for "([^"]+)"$/
* @Transform /^address "([^"]+)", "([^"]+)", "([^"]+)", "([^"]+)" for "([^"]+)"$/
* @Transform /^address to "([^"]+)", "([^"]+)", "([^"]+)", "([^"]+)" for "([^"]+)"$/
*/
public function createNewAddressWith($cityName, $street, $postcode, $countryName, $customerName)
{

View file

@ -133,6 +133,15 @@ final class CheckoutContext implements Context
$this->currentPageResolver = $currentPageResolver;
}
/**
* @Given I was at the checkout summary step
*/
public function iWasAtTheCheckoutSummaryStep()
{
$this->iSpecifiedTheShippingAddress($this->createDefaultAddress());
$this->iProceedOrderWithShippingMethodAndPayment('Free', 'Offline');
}
/**
* @Given /^I proceed without selecting shipping address$/
*/
@ -142,8 +151,18 @@ final class CheckoutContext implements Context
$this->addressPage->nextStep();
}
/**
* @Given I have proceeded selecting :shippingMethodName shipping method
*/
public function iHaveProceededSelectingShippingMethod($shippingMethodName)
{
$this->iSelectShippingMethod($shippingMethodName);
$this->selectShippingPage->nextStep();
}
/**
* @Given I am at the checkout addressing step
* @When I go back to addressing step of the checkout
*/
public function iAmAtTheCheckoutAddressingStep()
{
@ -162,8 +181,9 @@ final class CheckoutContext implements Context
}
/**
* @When /^I specify the shipping (address as "([^"]+)", "([^"]+)", "([^"]+)", "([^"]+)" for "([^"]+)")$/
* @When /^I specify the shipping (address as "[^"]+", "[^"]+", "[^"]+", "[^"]+" for "[^"]+")$/
* @When /^I (do not specify any shipping address) information$/
* @When /^I change the shipping (address to "[^"]+", "[^"]+", "[^"]+", "[^"]+" for "[^"]+")$/
*/
public function iSpecifyTheShippingAddressAs(AddressInterface $address)
{
@ -418,6 +438,14 @@ final class CheckoutContext implements Context
$this->iChoosePaymentMethod($paymentMethodName);
}
/**
* @When I go back to shipping step of the checkout
*/
public function iGoBackToShippingStepOfTheCheckout()
{
$this->selectShippingPage->open();
}
/**
* @Given I have proceeded selecting :paymentMethodName payment method
* @When /^I (?:proceed|proceeded) selecting "([^"]+)" payment method$/
@ -462,6 +490,14 @@ final class CheckoutContext implements Context
$this->addressPage->nextStep();
}
/**
* @When I return to the checkout summary step
*/
public function iReturnToTheCheckoutSummaryStep()
{
$this->completePage->open();
}
/**
* @Given I have confirmed my order
* @When I confirm my order
@ -544,6 +580,17 @@ final class CheckoutContext implements Context
);
}
/**
* @Then I should be on the checkout payment step
*/
public function iShouldBeOnTheCheckoutPaymentStep()
{
Assert::true(
$this->selectPaymentPage->isOpen(),
'Checkout payment page should be opened, but it is not.'
);
}
/**
* @Then I should be on the checkout summary step
*/
@ -643,6 +690,7 @@ final class CheckoutContext implements Context
/**
* @Given I am at the checkout payment step
* @When I go back to payment step of the checkout
*/
public function iAmAtTheCheckoutPaymentStep()
{
@ -665,6 +713,14 @@ final class CheckoutContext implements Context
$this->selectPaymentPage->selectPaymentMethod($paymentMethodName);
}
/**
* @When /^I do not modify anything$/
*/
public function iDoNotModifyAnything()
{
// Intentionally left blank to fulfill context expectation
}
/**
* @Then I should not be able to select :paymentMethodName payment method
*/
@ -688,6 +744,7 @@ final class CheckoutContext implements Context
}
/**
* @Given I have proceeded order with :shippingMethod shipping method and :paymentMethod payment
* @When I proceed order with :shippingMethod shipping method and :paymentMethod payment
*/
public function iProceedOrderWithShippingMethodAndPayment($shippingMethod, $paymentMethod)

View file

@ -11,6 +11,7 @@
namespace Sylius\Behat\Page\Shop\Checkout;
use Sylius\Behat\Page\SymfonyPageInterface;
use Sylius\Component\Core\Model\AddressInterface;
use Sylius\Component\Core\Model\ProductInterface;
use Sylius\Component\Core\Model\ShippingMethodInterface;
@ -19,7 +20,7 @@ use Sylius\Component\Payment\Model\PaymentMethodInterface;
/**
* @author Mateusz Zalewski <mateusz.zalewski@lakion.com>
*/
interface CompletePageInterface
interface CompletePageInterface extends SymfonyPageInterface
{
/**
* @param string $productName

View file

@ -11,7 +11,6 @@
namespace Sylius\Behat\Page\Shop\Checkout;
use Behat\Mink\Driver\Selenium2Driver;
use Behat\Mink\Exception\ElementNotFoundException;
use Sylius\Behat\Page\SymfonyPage;
@ -33,13 +32,6 @@ class SelectPaymentPage extends SymfonyPage implements SelectPaymentPageInterfac
*/
public function selectPaymentMethod($paymentMethod)
{
$driver = $this->getDriver();
if ($driver instanceof Selenium2Driver) {
$this->getDriver()->executeScript(sprintf('$(\'.item:contains("%s") .ui.radio.checkbox\').checkbox(\'check\')', $paymentMethod));
return;
}
$paymentMethodElement = $this->getElement('payment_method');
$paymentMethodElement->selectOption($paymentMethodElement->getAttribute('value'));
}
@ -77,7 +69,7 @@ class SelectPaymentPage extends SymfonyPage implements SelectPaymentPageInterfac
public function changeShippingMethod()
{
$this->getDocument()->pressButton('Change shipping method');
$this->getDocument()->clickLink('Change shipping method');
}
public function changeShippingMethodByStepLabel()

View file

@ -11,7 +11,6 @@
namespace Sylius\Behat\Page\Shop\Checkout;
use Behat\Mink\Driver\Selenium2Driver;
use Behat\Mink\Exception\ElementNotFoundException;
use Sylius\Behat\Page\SymfonyPage;
@ -33,13 +32,6 @@ class SelectShippingPage extends SymfonyPage implements SelectShippingPageInterf
*/
public function selectShippingMethod($shippingMethod)
{
$driver = $this->getDriver();
if ($driver instanceof Selenium2Driver) {
$this->getDriver()->executeScript(sprintf('$(\'.item:contains("%s") .ui.radio.checkbox\').checkbox(\'check\')', $shippingMethod));
return;
}
$shippingMethodElement = $this->getElement('shipping_method');
$shippingMethodValue = $this->getElement('shipping_method_option', ['%shipping_method%' => $shippingMethod])->getAttribute('value');
@ -103,7 +95,7 @@ class SelectShippingPage extends SymfonyPage implements SelectShippingPageInterf
public function changeAddress()
{
$this->getDocument()->pressButton('Change address');
$this->getDocument()->clickLink('Change address');
}
public function changeAddressByStepLabel()

View file

@ -15,30 +15,21 @@ winzou_state_machine:
completed: ~
transitions:
address:
from: [cart]
from: [cart, addressed, shipping_selected, payment_selected]
to: addressed
readdress:
from: [payment_selected, shipping_selected, addressed]
to: cart
select_shipping:
from: [addressed]
from: [addressed, shipping_selected, payment_selected]
to: shipping_selected
reselect_shipping:
from: [payment_selected, shipping_selected]
to: addressed
select_payment:
from: [shipping_selected]
from: [payment_selected, shipping_selected]
to: payment_selected
reselect_payment:
from: [payment_selected]
to: shipping_selected
complete:
from: [payment_selected]
to: completed
callbacks:
after:
sylius_process_cart:
on: ["address", "readdress", "select_shipping", "reselect_shipping", "select_payment", "reselect_payment"]
on: ["address", "select_shipping", "select_payment"]
do: ["@sylius.order_processing.order_processor", "process"]
args: ["object"]
sylius_update_exchange_rate:

View file

@ -30,23 +30,6 @@ sylius_shop_checkout_address:
route: sylius_shop_checkout_select_shipping
parameters: []
sylius_shop_checkout_readdress:
path: /readdress
methods: [PUT]
defaults:
_controller: sylius.controller.order:applyStateMachineTransitionAction
_sylius:
flash: false
repository:
method: find
arguments: [expr:service('sylius.context.cart').getCart()]
state_machine:
graph: sylius_order_checkout
transition: readdress
redirect:
route: sylius_shop_checkout_address
parameters: []
sylius_shop_checkout_select_shipping:
path: /select-shipping
methods: [GET, PUT]
@ -67,23 +50,6 @@ sylius_shop_checkout_select_shipping:
route: sylius_shop_checkout_select_payment
parameters: []
sylius_shop_checkout_reselect_shipping:
path: /reselect-shipping
methods: [PUT]
defaults:
_controller: sylius.controller.order:applyStateMachineTransitionAction
_sylius:
flash: false
repository:
method: find
arguments: [expr:service('sylius.context.cart').getCart()]
state_machine:
graph: sylius_order_checkout
transition: reselect_shipping
redirect:
route: sylius_shop_checkout_select_shipping
parameters: []
sylius_shop_checkout_select_payment:
path: /select-payment
methods: [GET, PUT]
@ -104,23 +70,6 @@ sylius_shop_checkout_select_payment:
route: sylius_shop_checkout_complete
parameters: []
sylius_shop_checkout_reselect_payment:
path: /reselect-payment
methods: [PUT]
defaults:
_controller: sylius.controller.order:applyStateMachineTransitionAction
_sylius:
flash: false
repository:
method: find
arguments: [expr:service('sylius.context.cart').getCart()]
state_machine:
graph: sylius_order_checkout
transition: reselect_payment
redirect:
route: sylius_shop_checkout_select_payment
parameters: []
sylius_shop_checkout_complete:
path: /complete
methods: [GET, PUT]

View file

@ -1,6 +0,0 @@
$(document).ready(function() {
$('button[data-remote-form], .steps .step.completed[data-remote-form]').on('click', function(e){
e.preventDefault();
$("#" + $(this).attr('data-remote-form')).submit();
});
});

View file

@ -9,40 +9,28 @@
{% endif %}
<div class="ui four steps">
<a data-remote-form="sylius_checkout_readdress" class="{{ steps['address'] }} step" href="#">
<a class="{{ steps['address'] }} step" href="{{ path('sylius_shop_checkout_address') }}">
<i class="map icon"></i>
<div class="content">
<div class="title">{{ 'sylius.ui.address'|trans }}</div>
</div>
</a>
<a data-remote-form="sylius_checkout_reselect_shipping" class="{{ steps['select_shipping'] }} step" href="#">
<a class="{{ steps['select_shipping'] }} step" href="{{ path('sylius_shop_checkout_select_shipping') }}">
<i class="truck icon"></i>
<div class="content">
<div class="title">{{ 'sylius.ui.shipping'|trans }}</div>
</div>
</a>
<a data-remote-form="sylius_checkout_reselect_payment" class="{{ steps['select_payment'] }} step" href="#">
<a class="{{ steps['select_payment'] }} step" href="{{ path('sylius_shop_checkout_select_payment') }}">
<i class="payment icon"></i>
<div class="content">
<div class="title">{{ 'sylius.ui.payment'|trans }}</div>
</div>
</a>
<div class="{{ steps['complete'] }} step">
<div class="{{ steps['complete'] }} step" href="{{ path('sylius_shop_checkout_complete') }}">
<i class="checkered flag icon"></i>
<div class="content">
<div class="title">{{ 'sylius.ui.complete'|trans }}</div>
</div>
</div>
</div>
<form id="sylius_checkout_readdress" action="{{ path('sylius_shop_checkout_readdress') }}" method="post">
<input type="hidden" name="_method" value="PUT" />
</form>
<form id="sylius_checkout_reselect_shipping" action="{{ path('sylius_shop_checkout_reselect_shipping') }}" method="post">
<input type="hidden" name="_method" value="PUT" />
</form>
<form id="sylius_checkout_reselect_payment" action="{{ path('sylius_shop_checkout_reselect_payment') }}" method="post">
<input type="hidden" name="_method" value="PUT" />
</form>

View file

@ -14,7 +14,7 @@
<div class="ui hidden divider"></div>
<div class="ui two column grid">
<div class="column">
<button data-remote-form="sylius_checkout_reselect_shipping" href="#" class="ui large icon labeled button"><i class="arrow left icon"></i> {{ 'sylius.ui.change_shipping_method'|trans }}</button>
<a href="{{ path('sylius_shop_checkout_select_shipping') }}" class="ui large icon labeled button"><i class="arrow left icon"></i> {{ 'sylius.ui.change_shipping_method'|trans }}</a>
</div>
<div class="right aligned column">
<button type="submit" id="next-step" class="ui large primary icon labeled button"><i class="arrow right icon"></i> {{ 'sylius.ui.next'|trans }}</button>

View file

@ -16,7 +16,7 @@
<div class="ui hidden divider"></div>
<div class="ui two column grid">
<div class="column">
<button data-remote-form="sylius_checkout_readdress" class="ui large icon labeled button"><i class="arrow left icon"></i> {{ 'sylius.ui.change_address'|trans }}</button>
<a href="{{ path('sylius_shop_checkout_address') }}" class="ui large icon labeled button"><i class="arrow left icon"></i> {{ 'sylius.ui.change_address'|trans }}</a>
</div>
<div class="right aligned column">
<button type="submit" id="next-step" class="ui large primary icon labeled button"><i class="arrow right icon"></i> {{ 'sylius.ui.next'|trans }}</button>

View file

@ -1,77 +0,0 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sylius\Tests\Controller;
use Symfony\Component\HttpFoundation\Response;
/**
* @author Mateusz Zalewski <mateusz.zalewski@lakion.com>
*/
final class CheckoutReaddressingApiTest extends CheckoutApiTestCase
{
/**
* @test
*/
public function it_denies_order_readdressing_for_non_authenticated_user()
{
$this->client->request('PUT', '/api/checkouts/readdress/1');
$response = $this->client->getResponse();
$this->assertResponse($response, 'authentication/access_denied_response', Response::HTTP_UNAUTHORIZED);
}
/**
* @test
*/
public function it_does_not_allow_to_readdress_unexisting_order()
{
$this->loadFixturesFromFile('authentication/api_administrator.yml');
$this->client->request('PUT', '/api/checkouts/readdress/1', [], [], static::$authorizedHeaderWithContentType);
$response = $this->client->getResponse();
$this->assertResponseCode($response, Response::HTTP_NOT_FOUND);
}
/**
* @test
*/
public function it_does_not_allow_to_readdress_order_that_is_not_addressed()
{
$this->loadFixturesFromFile('authentication/api_administrator.yml');
$checkoutData = $this->loadFixturesFromFile('resources/checkout.yml');
$url = sprintf('/api/checkouts/readdress/%d', $checkoutData['order1']->getId());
$this->client->request('PUT', $url, [], [], static::$authorizedHeaderWithContentType);
$response = $this->client->getResponse();
$this->assertResponseCode($response, Response::HTTP_BAD_REQUEST);
}
/**
* @test
*/
public function it_allows_to_readdress_addressed_order()
{
$this->loadFixturesFromFile('authentication/api_administrator.yml');
$checkoutData = $this->loadFixturesFromFile('resources/checkout.yml');
$orderId = $checkoutData['order1']->getId();
$this->addressOrder($orderId);
$url = sprintf('/api/checkouts/readdress/%d', $orderId);
$this->client->request('PUT', $url, [], [], static::$authorizedHeaderWithContentType);
$response = $this->client->getResponse();
$this->assertResponse($response, 'checkout/readdressing_response', Response::HTTP_OK);
}
}

View file

@ -1,82 +0,0 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sylius\Tests\Controller;
use Symfony\Component\HttpFoundation\Response;
/**
* @author Mateusz Zalewski <mateusz.zalewski@lakion.com>
*/
final class CheckoutPaymentShippingApiTest extends CheckoutApiTestCase
{
/**
* @test
*/
public function it_denies_reselecting_order_payment_for_non_authenticated_user()
{
$this->client->request('PUT', '/api/checkouts/reselect-payment/1');
$response = $this->client->getResponse();
$this->assertResponse($response, 'authentication/access_denied_response', Response::HTTP_UNAUTHORIZED);
}
/**
* @test
*/
public function it_does_not_allow_to_reselect_paymeny_of_unexisting_order()
{
$this->loadFixturesFromFile('authentication/api_administrator.yml');
$this->client->request('PUT', '/api/checkouts/reselect-payment/1', [], [], static::$authorizedHeaderWithContentType);
$response = $this->client->getResponse();
$this->assertResponseCode($response, Response::HTTP_NOT_FOUND);
}
/**
* @test
*/
public function it_does_not_allow_to_reselect_payment_of_order_that_has_no_payment_method_selected()
{
$this->loadFixturesFromFile('authentication/api_administrator.yml');
$checkoutData = $this->loadFixturesFromFile('resources/checkout.yml');
$orderId = $checkoutData['order1']->getId();
$this->addressOrder($orderId);
$url = sprintf('/api/checkouts/reselect-payment/%d', $orderId);
$this->client->request('PUT', $url, [], [], static::$authorizedHeaderWithContentType);
$response = $this->client->getResponse();
$this->assertResponseCode($response, Response::HTTP_BAD_REQUEST);
}
/**
* @test
*/
public function it_allows_to_reselect_paymeny_of_order_with_paymeny_method_selected()
{
$this->loadFixturesFromFile('authentication/api_administrator.yml');
$checkoutData = $this->loadFixturesFromFile('resources/checkout.yml');
$orderId = $checkoutData['order1']->getId();
$this->addressOrder($orderId);
$this->selectOrderShippingMethod($orderId, $checkoutData['ups']->getId());
$this->selectOrderPaymentMethod($orderId, $checkoutData['cash_on_delivery']->getId());
$url = sprintf('/api/checkouts/reselect-payment/%d', $orderId);
$this->client->request('PUT', $url, [], [], static::$authorizedHeaderWithContentType);
$response = $this->client->getResponse();
$this->assertResponse($response, 'checkout/reselect_payment_response', Response::HTTP_OK);
}
}

View file

@ -1,81 +0,0 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sylius\Tests\Controller;
use Symfony\Component\HttpFoundation\Response;
/**
* @author Mateusz Zalewski <mateusz.zalewski@lakion.com>
*/
final class CheckoutReselectingShippingApiTest extends CheckoutApiTestCase
{
/**
* @test
*/
public function it_denies_reselecting_order_shipping_for_non_authenticated_user()
{
$this->client->request('PUT', '/api/checkouts/reselect-shipping/1');
$response = $this->client->getResponse();
$this->assertResponse($response, 'authentication/access_denied_response', Response::HTTP_UNAUTHORIZED);
}
/**
* @test
*/
public function it_does_not_allow_to_reselect_shipping_of_unexisting_order()
{
$this->loadFixturesFromFile('authentication/api_administrator.yml');
$this->client->request('PUT', '/api/checkouts/reselect-shipping/1', [], [], static::$authorizedHeaderWithContentType);
$response = $this->client->getResponse();
$this->assertResponseCode($response, Response::HTTP_NOT_FOUND);
}
/**
* @test
*/
public function it_does_not_allow_to_reselect_shipping_of_order_that_has_no_shipment_method_selected()
{
$this->loadFixturesFromFile('authentication/api_administrator.yml');
$checkoutData = $this->loadFixturesFromFile('resources/checkout.yml');
$orderId = $checkoutData['order1']->getId();
$this->addressOrder($orderId);
$url = sprintf('/api/checkouts/reselect-shipping/%d', $orderId);
$this->client->request('PUT', $url, [], [], static::$authorizedHeaderWithContentType);
$response = $this->client->getResponse();
$this->assertResponseCode($response, Response::HTTP_BAD_REQUEST);
}
/**
* @test
*/
public function it_allows_to_reselect_shipping_of_order_with_shipment_method_selected()
{
$this->loadFixturesFromFile('authentication/api_administrator.yml');
$checkoutData = $this->loadFixturesFromFile('resources/checkout.yml');
$orderId = $checkoutData['order1']->getId();
$this->addressOrder($orderId);
$this->selectOrderShippingMethod($orderId, $checkoutData['ups']->getId());
$url = sprintf('/api/checkouts/reselect-shipping/%d', $orderId);
$this->client->request('PUT', $url, [], [], static::$authorizedHeaderWithContentType);
$response = $this->client->getResponse();
$this->assertResponse($response, 'checkout/reselect_shipping_response', Response::HTTP_OK);
}
}