Skip to content

Commit 9085dc9

Browse files
MTO-60: [Constraint] Verify that address was used for checkout is saved as default for Customer without addresses
- Functional test implemented.
1 parent b56df96 commit 9085dc9

File tree

7 files changed

+66
-19
lines changed

7 files changed

+66
-19
lines changed

dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/OnePageCheckoutTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
* 14. Perform assertions.
3434
*
3535
* @group One_Page_Checkout
36-
* @ZephyrId MAGETWO-27485, MAGETWO-12412, MAGETWO-12429
36+
* @ZephyrId MAGETWO-27485, MAGETWO-12412, MAGETWO-12429, MAGETWO-42598, MAGETWO-42599
3737
* @ZephyrId MAGETWO-12444, MAGETWO-12848, MAGETWO-12849, MAGETWO-12850
3838
*/
3939
class OnePageCheckoutTest extends Scenario

dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/OnePageCheckoutTest.xml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,9 @@
172172
<data name="tag" xsi:type="string">stable:no</data>
173173
<data name="products/0" xsi:type="string">catalogProductSimple::simple_with_tier_price_and_order_qty_3</data>
174174
<data name="customer/dataset" xsi:type="string">default</data>
175-
<data name="checkoutMethod" xsi:type="string">guest</data>
176-
<data name="shippingAddress/dataset" xsi:type="string">UK_address</data>
175+
<data name="checkoutMethod" xsi:type="string">login</data>
176+
<data name="shippingAddress/dataset" xsi:type="string">UK_address_without_email</data>
177+
<data name="billingAddress/dataset" xsi:type="string">UK_address_2_without_email</data>
177178
<data name="shipping/shipping_service" xsi:type="string">Flat Rate</data>
178179
<data name="shipping/shipping_method" xsi:type="string">Fixed</data>
179180
<data name="prices" xsi:type="array">
@@ -183,6 +184,7 @@
183184
<data name="configData" xsi:type="string">banktransfer_specificcountry_gb</data>
184185
<constraint name="Magento\Checkout\Test\Constraint\AssertOrderSuccessPlacedMessage" />
185186
<constraint name="Magento\Checkout\Test\Constraint\AssertMinicartEmpty" />
187+
<constraint name="Magento\Customer\Test\Constraint\AssertCustomerDefaultAddressFrontendAddressBook" />
186188
<constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal" />
187189
</variation>
188190
<variation name="OnePageCheckoutTestVariation10" summary="One Page Checkout with all product types">
@@ -203,6 +205,7 @@
203205
</data>
204206
<data name="payment/method" xsi:type="string">checkmo</data>
205207
<data name="configData" xsi:type="string">checkmo</data>
208+
<constraint name="Magento\Customer\Test\Constraint\AssertCustomerDefaultAddressFrontendAddressBook" />
206209
<constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal" />
207210
</variation>
208211
</testCase>

dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/FillBillingInformationStep.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66

77
namespace Magento\Checkout\Test\TestStep;
88

9+
use Magento\Checkout\Test\Constraint\AssertBillingAddressSameAsShippingCheckbox;
910
use Magento\Checkout\Test\Page\CheckoutOnepage;
1011
use Magento\Customer\Test\Fixture\Address;
1112
use Magento\Mtf\TestStep\TestStepInterface;
12-
use Magento\Checkout\Test\Constraint\AssertBillingAddressSameAsShippingCheckbox;
1313

1414
/**
1515
* Fill billing information.
@@ -76,7 +76,7 @@ public function __construct(
7676
/**
7777
* Fill billing address.
7878
*
79-
* @return void
79+
* @return array
8080
*/
8181
public function run()
8282
{
@@ -91,5 +91,8 @@ public function run()
9191
}
9292
$selectedPaymentMethod->getBillingBlock()->fillBilling($this->billingAddress);
9393
}
94+
return [
95+
'billingAddress' => $this->billingAddress
96+
];
9497
}
9598
}

dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/FillShippingAddressStep.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,15 @@ public function __construct(
4545
/**
4646
* Fill shipping address.
4747
*
48-
* @return void
48+
* @return array
4949
*/
5050
public function run()
5151
{
5252
if ($this->shippingAddress) {
5353
$this->checkoutOnepage->getShippingBlock()->fill($this->shippingAddress);
5454
}
55+
return [
56+
'shippingAddress' => $this->shippingAddress
57+
];
5558
}
5659
}

dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerDefaultAddressFrontendAddressBook.php

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66

77
namespace Magento\Customer\Test\Constraint;
88

9+
use Magento\Customer\Test\Block\Address\Renderer;
910
use Magento\Customer\Test\Fixture\Address;
10-
use Magento\Customer\Test\Page\CustomerAccountIndex;
1111
use Magento\Customer\Test\Page\CustomerAccountAddress;
12+
use Magento\Customer\Test\Page\CustomerAccountIndex;
1213
use Magento\Mtf\Constraint\AbstractConstraint;
1314

1415
/**
@@ -20,25 +21,32 @@ class AssertCustomerDefaultAddressFrontendAddressBook extends AbstractConstraint
2021
* Asserts that Default Billing Address and Default Shipping Address equal to data from fixture.
2122
*
2223
* @param CustomerAccountIndex $customerAccountIndex
23-
* @param CustomerAccountAddress $customerAccountAddress
24-
* @param Address $address
24+
* @param CustomerAccountAddress $customerAddress
25+
* @param Address|null $shippingAddress
26+
* @param Address|null $billingAddress
2527
* @return void
2628
*/
2729
public function processAssert(
2830
CustomerAccountIndex $customerAccountIndex,
29-
CustomerAccountAddress $customerAccountAddress,
30-
Address $address
31+
CustomerAccountAddress $customerAddress,
32+
Address $shippingAddress,
33+
Address $billingAddress = null
3134
) {
35+
$customerAccountIndex->open();
3236
$customerAccountIndex->getAccountMenuBlock()->openMenuItem('Address Book');
33-
$addressRenderer = $this->objectManager->create(
34-
\Magento\Customer\Test\Block\Address\Renderer::class,
35-
['address' => $address, 'type' => 'html']
36-
);
37-
$addressToVerify = $addressRenderer->render();
37+
38+
$shippingAddressRendered = $this->createAddressRenderer($shippingAddress)->render();
39+
$validated =
40+
$shippingAddressRendered == $customerAddress->getDefaultAddressBlock()->getDefaultShippingAddress();
41+
42+
if (null !== $billingAddress) {
43+
$billingAddressRendered = $customerAddress->getDefaultAddressBlock()->getDefaultBillingAddress();
44+
$validated =
45+
$validated && ($billingAddressRendered == $this->createAddressRenderer($billingAddress)->render());
46+
}
3847

3948
\PHPUnit_Framework_Assert::assertTrue(
40-
$addressToVerify == $customerAccountAddress->getDefaultAddressBlock()->getDefaultBillingAddress()
41-
&& $addressToVerify == $customerAccountAddress->getDefaultAddressBlock()->getDefaultShippingAddress(),
49+
$validated,
4250
'Customer default address on address book tab is not matching the fixture.'
4351
);
4452
}
@@ -52,4 +60,18 @@ public function toString()
5260
{
5361
return 'Default billing and shipping address form is correct.';
5462
}
63+
64+
/**
65+
* Instantiate Renderer object.
66+
*
67+
* @param Address $address
68+
* @return Renderer
69+
*/
70+
private function createAddressRenderer(Address $address)
71+
{
72+
return $this->objectManager->create(
73+
Renderer::class,
74+
['address' => $address, 'type' => 'html']
75+
);
76+
}
5577
}

dev/tests/functional/tests/app/Magento/Customer/Test/Repository/Address.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,18 @@
189189
<field name="telephone" xsi:type="string">555-55-555-55</field>
190190
</dataset>
191191

192+
<dataset name="UK_address_2_without_email">
193+
<field name="firstname" xsi:type="string">Billy</field>
194+
<field name="lastname" xsi:type="string">Holiday</field>
195+
<field name="company" xsi:type="string">Magento %isolation%</field>
196+
<field name="city" xsi:type="string">Liverpool</field>
197+
<field name="street" xsi:type="string">99 Henry St</field>
198+
<field name="postcode" xsi:type="string">SE1 7RW</field>
199+
<field name="country_id" xsi:type="string">United Kingdom</field>
200+
<field name="region" xsi:type="string">Liverpool</field>
201+
<field name="telephone" xsi:type="string">555-55-555-55</field>
202+
</dataset>
203+
192204
<dataset name="UK_address_without_email">
193205
<field name="firstname" xsi:type="string">Jane</field>
194206
<field name="lastname" xsi:type="string">Doe</field>

dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/UpdateCustomerFrontendEntityTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,10 @@ public function test(
156156
$this->customerAddressEdit->getEditForm()->fill($address);
157157
$this->customerAddressEdit->getEditForm()->saveAddress();
158158

159-
return ['customer' => $this->prepareCustomer($customer, $initialCustomer)];
159+
return [
160+
'customer' => $this->prepareCustomer($customer, $initialCustomer),
161+
'shippingAddress' => $address,
162+
'billingAddress' => $address
163+
];
160164
}
161165
}

0 commit comments

Comments
 (0)