Skip to content

Commit a0186de

Browse files
committed
MAGETWO-92137: Refreshing page deletes shipping address on guest checkout if module-persistent is enabled
1 parent 0157463 commit a0186de

File tree

9 files changed

+53
-137
lines changed

9 files changed

+53
-137
lines changed

app/code/Magento/Persistent/Test/Unit/Observer/CheckExpirePersistentQuoteObserverTest.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public function testExecuteWhenCanNotApplyPersistentData()
9191
->expects($this->once())
9292
->method('canProcess')
9393
->with($this->observerMock)
94-
->will($this->returnValue(false));
94+
->willReturn(false);
9595
$this->persistentHelperMock->expects($this->never())->method('isEnabled');
9696
$this->model->execute($this->observerMock);
9797
}
@@ -102,8 +102,8 @@ public function testExecuteWhenPersistentIsNotEnabled()
102102
->expects($this->once())
103103
->method('canProcess')
104104
->with($this->observerMock)
105-
->will($this->returnValue(true));
106-
$this->persistentHelperMock->expects($this->once())->method('isEnabled')->will($this->returnValue(false));
105+
->willReturn(true);
106+
$this->persistentHelperMock->expects($this->once())->method('isEnabled')->willReturn(false);
107107
$this->eventManagerMock->expects($this->never())->method('dispatch');
108108
$this->model->execute($this->observerMock);
109109
}
@@ -116,6 +116,7 @@ public function testExecuteWhenPersistentIsNotEnabled()
116116
* @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $expireCounter
117117
* @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $dispatchCounter
118118
* @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $setCustomerIdCounter
119+
* @return void
119120
* @dataProvider requestDataProvider
120121
*/
121122
public function testExecuteWhenPersistentIsEnabled(
@@ -124,29 +125,29 @@ public function testExecuteWhenPersistentIsEnabled(
124125
\PHPUnit_Framework_MockObject_Matcher_InvokedCount $expireCounter,
125126
\PHPUnit_Framework_MockObject_Matcher_InvokedCount $dispatchCounter,
126127
\PHPUnit_Framework_MockObject_Matcher_InvokedCount $setCustomerIdCounter
127-
) {
128+
): void {
128129
$this->persistentHelperMock
129130
->expects($this->once())
130131
->method('canProcess')
131132
->with($this->observerMock)
132-
->will($this->returnValue(true));
133-
$this->persistentHelperMock->expects($this->once())->method('isEnabled')->will($this->returnValue(true));
134-
$this->sessionMock->expects($this->once())->method('isPersistent')->will($this->returnValue(false));
133+
->willReturn(true);
134+
$this->persistentHelperMock->expects($this->once())->method('isEnabled')->willReturn(true);
135+
$this->sessionMock->expects($this->once())->method('isPersistent')->willReturn(false);
135136
$this->customerSessionMock
136137
->expects($this->atLeastOnce())
137138
->method('isLoggedIn')
138-
->will($this->returnValue(false));
139+
->willReturn(false);
139140
$this->checkoutSessionMock
140141
->expects($this->atLeastOnce())
141142
->method('getQuoteId')
142-
->will($this->returnValue(10));
143+
->willReturn(10);
143144
$this->eventManagerMock->expects($dispatchCounter)->method('dispatch');
144145
$this->quoteManagerMock->expects($expireCounter)->method('expire');
145146
$this->customerSessionMock
146147
->expects($setCustomerIdCounter)
147148
->method('setCustomerId')
148149
->with(null)
149-
->will($this->returnSelf());
150+
->willReturnSelf();
150151
$this->requestMock->expects($this->atLeastOnce())->method('getRequestUri')->willReturn($refererUri);
151152
$this->requestMock
152153
->expects($this->atLeastOnce())

dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Checkout/ActionGroup/NavigateToCheckoutActionGroup.xml

Lines changed: 0 additions & 16 deletions
This file was deleted.

dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Checkout/Page/GuestCheckoutReviewAndPaymentsPage.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
-->
88

99
<pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/PageObject.xsd">
10-
<page name="GuestCheckoutPage" url="/checkout/#payment" area="storefront" module="Checkout">
10+
<page name="GuestCheckoutReviewAndPaymentsPage" url="/checkout/#payment" area="storefront" module="Magento_Checkout">
1111
<section name="PaymentMethodSection"/>
1212
<section name="ShipToSection"/>
1313
</page>

dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Checkout/Section/CheckoutShippingGuestInfoSection.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,7 @@
1717
<element name="region" type="select" selector="select[name=region_id]"/>
1818
<element name="postcode" type="input" selector="input[name=postcode]"/>
1919
<element name="telephone" type="input" selector="input[name=telephone]"/>
20+
<element name="next" type="button" selector="button.button.action.continue.primary" timeout="30"/>
21+
<element name="firstShippingMethod" type="radio" selector=".row:nth-of-type(1) .col-method .radio"/>
2022
</section>
2123
</sections>

dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Checkout/Section/GuestCheckoutPaymentSection.xml

Lines changed: 0 additions & 18 deletions
This file was deleted.

dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Checkout/Section/GuestCheckoutShippingSection.xml

Lines changed: 0 additions & 23 deletions
This file was deleted.

dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Checkout/Section/PaymentMethodSection.xml

Lines changed: 0 additions & 14 deletions
This file was deleted.

dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Checkout/Section/ShipToSection.xml

Lines changed: 0 additions & 14 deletions
This file was deleted.

dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Persistent/Test/GuestCheckoutWithEnabledPersistentTest.xml

Lines changed: 39 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -26,60 +26,58 @@
2626
</before>
2727
<after>
2828
<createData entity="PersistentConfigDefault" stepKey="setDefaultPersistentState"/>
29-
<actionGroup ref="logout" stepKey="adminLogout"/>
3029
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
3130
<deleteData createDataKey="createProduct" stepKey="deleteProduct"/>
3231
</after>
3332
<!-- Add simple product to cart -->
34-
<actionGroup stepKey="addProductToCart1" ref="AddSimpleProductToCart">
33+
<actionGroup ref="AddSimpleProductToCart" stepKey="addProductToCart1">
3534
<argument name="product" value="$$createProduct$$"/>
3635
</actionGroup>
3736
<!-- Navigate to checkout -->
38-
<actionGroup stepKey="addProductNavigateToCheckout" ref="NavigateToCheckoutActionGroup"/>
37+
<actionGroup ref="GoToCheckoutFromMinicartActionGroup" stepKey="navigateToCheckoutFromMinicart"/>
3938
<!-- Fill Shipping Address form -->
40-
<fillField selector="{{GuestCheckoutShippingSection.email}}" userInput="{{CustomerEntityOne.email}}" stepKey="enterEmail"/>
41-
<fillField selector="{{GuestCheckoutShippingSection.firstName}}" userInput="{{CustomerEntityOne.firstname}}" stepKey="enterFirstName"/>
42-
<fillField selector="{{GuestCheckoutShippingSection.lastName}}" userInput="{{CustomerEntityOne.lastname}}" stepKey="enterLastName"/>
43-
<fillField selector="{{GuestCheckoutShippingSection.street}}" userInput="{{CustomerAddressSimple.street[0]}}" stepKey="enterStreet"/>
44-
<fillField selector="{{GuestCheckoutShippingSection.city}}" userInput="{{CustomerAddressSimple.city}}" stepKey="enterCity"/>
45-
<selectOption selector="{{GuestCheckoutShippingSection.region}}" userInput="{{CustomerAddressSimple.state}}" stepKey="selectRegion"/>
46-
<fillField selector="{{GuestCheckoutShippingSection.postcode}}" userInput="{{CustomerAddressSimple.postcode}}" stepKey="enterPostcode"/>
47-
<fillField selector="{{GuestCheckoutShippingSection.telephone}}" userInput="{{CustomerAddressSimple.telephone}}" stepKey="enterTelephone"/>
39+
<fillField selector="{{CheckoutShippingGuestInfoSection.email}}" userInput="{{CustomerEntityOne.email}}" stepKey="enterEmail"/>
40+
<fillField selector="{{CheckoutShippingGuestInfoSection.firstName}}" userInput="{{CustomerEntityOne.firstname}}" stepKey="enterFirstName"/>
41+
<fillField selector="{{CheckoutShippingGuestInfoSection.lastName}}" userInput="{{CustomerEntityOne.lastname}}" stepKey="enterLastName"/>
42+
<fillField selector="{{CheckoutShippingGuestInfoSection.street}}" userInput="{{CustomerAddressSimple.street[0]}}" stepKey="enterStreet"/>
43+
<fillField selector="{{CheckoutShippingGuestInfoSection.city}}" userInput="{{CustomerAddressSimple.city}}" stepKey="enterCity"/>
44+
<selectOption selector="{{CheckoutShippingGuestInfoSection.region}}" userInput="{{CustomerAddressSimple.state}}" stepKey="selectRegion"/>
45+
<fillField selector="{{CheckoutShippingGuestInfoSection.postcode}}" userInput="{{CustomerAddressSimple.postcode}}" stepKey="enterPostcode"/>
46+
<fillField selector="{{CheckoutShippingGuestInfoSection.telephone}}" userInput="{{CustomerAddressSimple.telephone}}" stepKey="enterTelephone"/>
4847
<waitForLoadingMaskToDisappear stepKey="waitForLoadingMask"/>
49-
<click selector="{{GuestCheckoutShippingSection.firstShippingMethod}}" stepKey="selectFirstShippingMethod"/>
48+
<click selector="{{CheckoutShippingGuestInfoSection.firstShippingMethod}}" stepKey="selectFirstShippingMethod"/>
5049
<!-- Check that have the same values after page reload -->
51-
<amOnPage url="{{CheckoutPage.url}}" stepKey="amOnCheckoutPage2"/>
52-
<waitForLoadingMaskToDisappear stepKey="waitForLoadingMask2"/>
53-
<seeInField stepKey="seeEmailtOnCheckout" selector="{{GuestCheckoutShippingSection.email}}" userInput="{{CustomerEntityOne.email}}" />
54-
<seeInField stepKey="seeFirstnameOnCheckout" selector="{{GuestCheckoutShippingSection.firstName}}" userInput="{{CustomerEntityOne.firstName}}" />
55-
<seeInField stepKey="seeLastnameOnCheckout" selector="{{GuestCheckoutShippingSection.lastName}}" userInput="{{CustomerEntityOne.lastName}}" />
56-
<seeInField stepKey="seeStreetOnCheckout" selector="{{GuestCheckoutShippingSection.street}}" userInput="{{CustomerAddressSimple.street[0]}}" />
57-
<seeInField stepKey="seeCityOnCheckout" selector="{{GuestCheckoutShippingSection.city}}" userInput="{{CustomerAddressSimple.city}}" />
58-
<seeInField stepKey="seeStateOnCheckout" selector="{{GuestCheckoutShippingSection.region}}" userInput="{{CustomerAddressSimple.state}}" />
59-
<seeInField stepKey="seePostcodeOnCheckout" selector="{{GuestCheckoutShippingSection.postcode}}" userInput="{{CustomerAddressSimple.postcode}}" />
60-
<seeInField stepKey="seePhoneOnCheckout" selector="{{GuestCheckoutShippingSection.telephone}}" userInput="{{CustomerAddressSimple.telephone}}" />
61-
<waitForElement selector="{{GuestCheckoutShippingSection.next}}" time="30" stepKey="waitForNextButton"/>
50+
<amOnPage url="{{CheckoutPage.url}}" stepKey="amOnCheckoutShippingInfoPage"/>
51+
<waitForPageLoad stepKey="waitForShippingPageReload"/>
52+
<seeInField selector="{{CheckoutShippingGuestInfoSection.email}}" userInput="{{CustomerEntityOne.email}}" stepKey="seeEmailOnCheckout" />
53+
<seeInField selector="{{CheckoutShippingGuestInfoSection.firstName}}" userInput="{{CustomerEntityOne.firstName}}" stepKey="seeFirstnameOnCheckout" />
54+
<seeInField selector="{{CheckoutShippingGuestInfoSection.lastName}}" userInput="{{CustomerEntityOne.lastName}}" stepKey="seeLastnameOnCheckout" />
55+
<seeInField selector="{{CheckoutShippingGuestInfoSection.street}}" userInput="{{CustomerAddressSimple.street[0]}}" stepKey="seeStreetOnCheckout" />
56+
<seeInField selector="{{CheckoutShippingGuestInfoSection.city}}" userInput="{{CustomerAddressSimple.city}}" stepKey="seeCityOnCheckout" />
57+
<seeInField selector="{{CheckoutShippingGuestInfoSection.region}}" userInput="{{CustomerAddressSimple.state}}" stepKey="seeStateOnCheckout" />
58+
<seeInField selector="{{CheckoutShippingGuestInfoSection.postcode}}" userInput="{{CustomerAddressSimple.postcode}}" stepKey="seePostcodeOnCheckout" />
59+
<seeInField selector="{{CheckoutShippingGuestInfoSection.telephone}}" userInput="{{CustomerAddressSimple.telephone}}" stepKey="seePhoneOnCheckout" />
6260
<!-- Click next button to open payment section -->
63-
<click selector="{{GuestCheckoutShippingSection.next}}" stepKey="clickNext"/>
64-
<waitForElement selector="{{GuestCheckoutPaymentSection.placeOrder}}" time="30" stepKey="waitForPlaceOrderButton"/>
61+
<click selector="{{CheckoutShippingGuestInfoSection.next}}" stepKey="clickNext"/>
62+
<actionGroup ref="CheckoutSelectCheckMoneyOrderPaymentActionGroup" stepKey="guestSelectCheckMoneyOrderPayment" />
6563
<!-- Reload payment section -->
66-
<amOnPage url="{{GuestCheckoutPage.url}}" stepKey="amOnCheckoutShipToPage"/>
67-
<waitForElement selector="{{GuestCheckoutPaymentSection.placeOrder}}" time="30" stepKey="waitForPlaceOrderButton2"/>
64+
<amOnPage url="{{GuestCheckoutReviewAndPaymentsPage.url}}" stepKey="amOnCheckoutPaymentsPage"/>
65+
<waitForPageLoad stepKey="waitForPaymentPageReload"/>
6866
<!-- Check that address block contains correct information -->
69-
<see stepKey="seeBilllingFirstName" selector="{{PaymentMethodSection.billingAddress}}" userInput="{{CustomerAddressSimple.firstName}}" />
70-
<see stepKey="seeBilllingLastName" selector="{{PaymentMethodSection.billingAddress}}" userInput="{{CustomerAddressSimple.lastName}}" />
71-
<see stepKey="seeBilllingStreet" selector="{{PaymentMethodSection.billingAddress}}" userInput="{{CustomerAddressSimple.street[0]}}" />
72-
<see stepKey="seeBilllingCity" selector="{{PaymentMethodSection.billingAddress}}" userInput="{{CustomerAddressSimple.city}}" />
73-
<see stepKey="seeBilllingState" selector="{{PaymentMethodSection.billingAddress}}" userInput="{{CustomerAddressSimple.state}}" />
74-
<see stepKey="seeBilllingPostcode" selector="{{PaymentMethodSection.billingAddress}}" userInput="{{CustomerAddressSimple.postcode}}" />
75-
<see stepKey="seeBilllingTelephone" selector="{{PaymentMethodSection.billingAddress}}" userInput="{{CustomerAddressSimple.telephone}}" />
67+
<see selector="{{CheckoutPaymentSection.billingAddress}}" userInput="{{CustomerAddressSimple.firstName}}" stepKey="seeBilllingFirstName" />
68+
<see selector="{{CheckoutPaymentSection.billingAddress}}" userInput="{{CustomerAddressSimple.lastName}}" stepKey="seeBilllingLastName" />
69+
<see selector="{{CheckoutPaymentSection.billingAddress}}" userInput="{{CustomerAddressSimple.street[0]}}" stepKey="seeBilllingStreet" />
70+
<see selector="{{CheckoutPaymentSection.billingAddress}}" userInput="{{CustomerAddressSimple.city}}" stepKey="seeBilllingCity" />
71+
<see selector="{{CheckoutPaymentSection.billingAddress}}" userInput="{{CustomerAddressSimple.state}}" stepKey="seeBilllingState" />
72+
<see selector="{{CheckoutPaymentSection.billingAddress}}" userInput="{{CustomerAddressSimple.postcode}}" stepKey="seeBilllingPostcode" />
73+
<see selector="{{CheckoutPaymentSection.billingAddress}}" userInput="{{CustomerAddressSimple.telephone}}" stepKey="seeBilllingTelephone" />
7674
<!-- Check that "Ship To" block contains correct information -->
77-
<see stepKey="seeShipToFirstName" selector="{{ShipToSection.shippingInformation}}" userInput="{{CustomerAddressSimple.firstName}}" />
78-
<see stepKey="seeShipToLastName" selector="{{ShipToSection.shippingInformation}}" userInput="{{CustomerAddressSimple.lastName}}" />
79-
<see stepKey="seeShipToStreet" selector="{{ShipToSection.shippingInformation}}" userInput="{{CustomerAddressSimple.street[0]}}" />
80-
<see stepKey="seeShipToCity" selector="{{ShipToSection.shippingInformation}}" userInput="{{CustomerAddressSimple.city}}" />
81-
<see stepKey="seeShipToState" selector="{{ShipToSection.shippingInformation}}" userInput="{{CustomerAddressSimple.state}}" />
82-
<see stepKey="seeShipToPostcode" selector="{{ShipToSection.shippingInformation}}" userInput="{{CustomerAddressSimple.postcode}}" />
83-
<see stepKey="seeShipToTelephone" selector="{{ShipToSection.shippingInformation}}" userInput="{{CustomerAddressSimple.telephone}}" />
75+
<see selector="{{CheckoutPaymentSection.shipToInfomation}}" userInput="{{CustomerAddressSimple.firstName}}" stepKey="seeShipToFirstName" />
76+
<see selector="{{CheckoutPaymentSection.shipToInfomation}}" userInput="{{CustomerAddressSimple.lastName}}" stepKey="seeShipToLastName" />
77+
<see selector="{{CheckoutPaymentSection.shipToInfomation}}" userInput="{{CustomerAddressSimple.street[0]}}" stepKey="seeShipToStreet" />
78+
<see selector="{{CheckoutPaymentSection.shipToInfomation}}" userInput="{{CustomerAddressSimple.city}}" stepKey="seeShipToCity" />
79+
<see selector="{{CheckoutPaymentSection.shipToInfomation}}" userInput="{{CustomerAddressSimple.state}}" stepKey="seeShipToState" />
80+
<see selector="{{CheckoutPaymentSection.shipToInfomation}}" userInput="{{CustomerAddressSimple.postcode}}" stepKey="seeShipToPostcode" />
81+
<see selector="{{CheckoutPaymentSection.shipToInfomation}}" userInput="{{CustomerAddressSimple.telephone}}" stepKey="seeShipToTelephone" />
8482
</test>
8583
</tests>

0 commit comments

Comments
 (0)