Skip to content

Commit 4fdda80

Browse files
committed
MTA-3252: Extend update customer on frontend test
1 parent 3c2d683 commit 4fdda80

File tree

10 files changed

+268
-38
lines changed

10 files changed

+268
-38
lines changed

dev/tests/functional/tests/app/Magento/Customer/Test/Block/Account/AddressesDefault.php

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use Magento\Mtf\Client\Locator;
1010

1111
/**
12-
* Addresses default block
12+
* Addresses default block.
1313
*
1414
*/
1515
class AddressesDefault extends Block
@@ -21,6 +21,20 @@ class AddressesDefault extends Block
2121
*/
2222
protected $defaultAddressContent = '.block-content';
2323

24+
/**
25+
* Billing address block selector.
26+
*
27+
* @var string
28+
*/
29+
protected $billingAddressBlock = '.box.box-address-billing .box-content';
30+
31+
/**
32+
* Shipping address block selector.
33+
*
34+
* @var string
35+
*/
36+
protected $shippingAddressBlock = '.box.box-address-shipping .box-content';
37+
2438
/**
2539
* Selector for change billing address.
2640
*
@@ -29,7 +43,7 @@ class AddressesDefault extends Block
2943
protected $changeBillingAddressSelector = '.box-address-billing a';
3044

3145
/**
32-
* Click on address book menu item
46+
* Click on address book menu item.
3347
*/
3448
public function goToAddressBook()
3549
{
@@ -46,4 +60,24 @@ public function getBlockText()
4660
{
4761
return $this->_rootElement->find($this->defaultAddressContent)->getText();
4862
}
63+
64+
/**
65+
* Returns Default Billing Address Text.
66+
*
67+
* @return string
68+
*/
69+
public function getDefaultBillingAddress()
70+
{
71+
return $this->_rootElement->find($this->billingAddressBlock)->getText();
72+
}
73+
74+
/**
75+
* Returns Default Shipping Address Text.
76+
*
77+
* @return string
78+
*/
79+
public function getDefaultShippingAddress()
80+
{
81+
return $this->_rootElement->find($this->shippingAddressBlock)->getText();
82+
}
4983
}

dev/tests/functional/tests/app/Magento/Customer/Test/Block/Account/Dashboard/Info.php

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,48 +9,54 @@
99
use Magento\Mtf\Block\Block;
1010

1111
/**
12-
* Class Info
13-
* Main block on customer account page
12+
* Main block on customer account page.
1413
*/
1514
class Info extends Block
1615
{
1716
/**
18-
* Css selector for Contact Information Edit Link
17+
* Css selector for Contact Information Edit Link.
1918
*
2019
* @var string
2120
*/
2221
protected $contactInfoEditLink = '.block-dashboard-info .box-information .action.edit';
2322

2423
/**
25-
* Css selector for Contact Information Change Password Link
24+
* Css selector for Contact Information box content.
25+
*
26+
* @var string
27+
*/
28+
protected $contactInfoBoxContent = '.box.box-information .box-content';
29+
30+
/**
31+
* Css selector for Contact Information Change Password Link.
2632
*
2733
* @var string
2834
*/
2935
protected $contactInfoChangePasswordLink = '.block-dashboard-info .box-information .action.change-password';
3036

3137
/**
32-
* Css selector for Contact Information Change Email Link
38+
* Css selector for Contact Information Change Email Link.
3339
*
3440
* @var string
3541
*/
3642
protected $contactInfoChangeEmailLink = '.form-edit-account .fieldset.info .checkbox#change-email';
3743

3844
/**
39-
* Css selector for Contact Information Change Password Checkbox
45+
* Css selector for Contact Information Change Password Checkbox.
4046
*
4147
* @var string
4248
*/
4349
protected $contactInfoChangePasswordCheckbox = '.form-edit-account .fieldset.info .checkbox#change-password';
4450

4551
/**
46-
* Dashboard Welcome block locator
52+
* Dashboard Welcome block locator.
4753
*
4854
* @var string
4955
*/
5056
protected $dashboardWelcome = '.block-dashboard-welcome .block-title';
5157

5258
/**
53-
* Click on Contact Information Edit Link
59+
* Click on Contact Information Edit Link.
5460
*
5561
* @return void
5662
*/
@@ -61,7 +67,7 @@ public function openEditContactInfo()
6167
}
6268

6369
/**
64-
* Click on Contact Information Edit Link
70+
* Click on Contact Information Edit Link.
6571
*
6672
* @return void
6773
*/
@@ -71,7 +77,7 @@ public function openChangePassword()
7177
}
7278

7379
/**
74-
* Get welcome text
80+
* Get welcome text.
7581
*
7682
* @return string
7783
*/
@@ -81,7 +87,7 @@ public function getWelcomeText()
8187
}
8288

8389
/**
84-
* Click on Change Email checkbox
90+
* Click on Change Email checkbox.
8591
*
8692
* @return void
8793
*/
@@ -91,12 +97,22 @@ public function openChangeEmail()
9197
}
9298

9399
/**
94-
* Click on Change Password checkbox
100+
* Click on Change Password checkbox.
95101
*
96102
* @return void
97103
*/
98104
public function checkChangePassword()
99105
{
100106
$this->_rootElement->find($this->contactInfoChangePasswordCheckbox)->click();
101107
}
108+
109+
/**
110+
* Get Contact Information block content.
111+
*
112+
* @return string
113+
*/
114+
public function getContactInfoContent()
115+
{
116+
return $this->_rootElement->find($this->contactInfoBoxContent)->getText();
117+
}
102118
}

dev/tests/functional/tests/app/Magento/Customer/Test/Block/Address/Renderer.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,6 @@ protected function getPattern()
5353
. "{{city}}, {{{$region}}}, {{postcode}}\n{{country_id}}\n{{depend}}T: {{telephone}}{{/depend}}"
5454
. "{{depend}}\nF: {{fax}}{{/depend}}{{depend}}\nVAT: {{vat_id}}{{/depend}}";
5555
break;
56-
case "htmlInBackend":
57-
$outputPattern = "{{depend}}{{prefix}} {{/depend}}{{firstname}} {{depend}}{{middlename}} {{/depend}}"
58-
. "{{lastname}}{{depend}} {{suffix}}{{/depend}}\n{{depend}}{{company}}\n{{/depend}}"
59-
. "{{city}}, {{{$region}}}, {{postcode}}\n{{country_id}}\n{{depend}}T: {{telephone}}{{/depend}}"
60-
. "{{depend}}\nF: {{fax}}{{/depend}}{{depend}}\nVAT: {{vat_id}}{{/depend}}";
61-
break;
6256
case "oneline":
6357
default:
6458
$outputPattern = "{{depend}}{{prefix}} {{/depend}}{{firstname}} {{depend}}{{middlename}} {{/depend}}"

dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Edit/Tab/Addresses.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ public function deleteCustomerAddress(Address $addressToDelete)
250250
{
251251
$addressRenderer = $this->objectManager->create(
252252
\Magento\Customer\Test\Block\Address\Renderer::class,
253-
['address' => $addressToDelete, 'type' => 'htmlInBackend']
253+
['address' => $addressToDelete, 'type' => 'html']
254254
);
255255
$addressToDelete = $addressRenderer->render();
256256

dev/tests/functional/tests/app/Magento/Customer/Test/Block/Form/CustomerForm.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\Mtf\Client\Element\SimpleElement;
1111
use Magento\Mtf\Fixture\FixtureInterface;
1212
use Magento\Customer\Test\Fixture\Customer;
13+
use Magento\Mtf\Client\Locator;
1314

1415
/**
1516
* Customer account edit form.
@@ -81,4 +82,32 @@ public function getValidationMessages(Customer $customer)
8182

8283
return $messages;
8384
}
85+
86+
/**
87+
* Get Customer first name from field.
88+
*
89+
* @return string
90+
*/
91+
public function getFirstName()
92+
{
93+
$mapping = $this->dataMapping();
94+
return $this->_rootElement->find(
95+
$mapping['firstname']['selector'],
96+
$mapping['firstname']['strategy']
97+
)->getValue();
98+
}
99+
100+
/**
101+
* Get Customer last name from field.
102+
*
103+
* @return string
104+
*/
105+
public function getLastName()
106+
{
107+
$mapping = $this->dataMapping();
108+
return $this->_rootElement->find(
109+
$mapping['lastname']['selector'],
110+
$mapping['lastname']['strategy']
111+
)->getValue();
112+
}
84113
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Customer\Test\Constraint;
8+
9+
use Magento\Customer\Test\Fixture\Address;
10+
use Magento\Customer\Test\Page\CustomerAccountIndex;
11+
use Magento\Customer\Test\Page\CustomerAccountAddress;
12+
use Magento\Mtf\Constraint\AbstractConstraint;
13+
14+
/**
15+
* Assert customers address on Address Book in Customer Account.
16+
*/
17+
class AssertCustomerDefaultAddressFrontendAddressBook extends AbstractConstraint
18+
{
19+
/**
20+
* Asserts that Default Billing Address and Default Shipping Address equal to data from fixture.
21+
*
22+
* @param CustomerAccountIndex $customerAccountIndex
23+
* @param CustomerAccountAddress $customerAccountAddress
24+
* @param Address $address
25+
* @return void
26+
*/
27+
public function processAssert(
28+
CustomerAccountIndex $customerAccountIndex,
29+
CustomerAccountAddress $customerAccountAddress,
30+
Address $address
31+
) {
32+
$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();
38+
39+
\PHPUnit_Framework_Assert::assertTrue(
40+
$addressToVerify == $customerAccountAddress->getDefaultAddressBlock()->getDefaultBillingAddress()
41+
&& $addressToVerify == $customerAccountAddress->getDefaultAddressBlock()->getDefaultShippingAddress(),
42+
'Customer default address on address book tab is not matching the fixture.'
43+
);
44+
}
45+
46+
/**
47+
* String representation of success assert.
48+
*
49+
* @return string
50+
*/
51+
public function toString()
52+
{
53+
return 'Default billing and shipping address form is correct.';
54+
}
55+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Customer\Test\Constraint;
8+
9+
use Magento\Customer\Test\Page\CustomerAccountIndex;
10+
use Magento\Customer\Test\Page\CustomerAccountEdit;
11+
use Magento\Customer\Test\Fixture\Customer;
12+
use Magento\Mtf\Constraint\AbstractConstraint;
13+
14+
/**
15+
* Assert customer name in Contact information block and Account info tab.
16+
*/
17+
class AssertCustomerNameFrontend extends AbstractConstraint
18+
{
19+
/**
20+
* Asserts that customer name in Contact information block and Account info tab matches name in fixture.
21+
*
22+
* @param CustomerAccountIndex $customerAccountIndex
23+
* @param CustomerAccountEdit $customerAccountEdit
24+
* @param Customer $customer
25+
* @return void
26+
*/
27+
public function processAssert(
28+
CustomerAccountIndex $customerAccountIndex,
29+
CustomerAccountEdit $customerAccountEdit,
30+
Customer $customer
31+
) {
32+
$customerName = $customer->getFirstname() . " " . $customer->getLastname();
33+
34+
$customerAccountIndex->open();
35+
$infoBlock = $customerAccountIndex->getInfoBlock()->getContactInfoContent();
36+
$infoBlock = explode("\n", $infoBlock);
37+
$nameInDashboard = $infoBlock[0];
38+
\PHPUnit_Framework_Assert::assertTrue(
39+
$nameInDashboard == $customerName,
40+
'Customer name in Contact info block is not matching the fixture.'
41+
);
42+
43+
$customerAccountIndex->getInfoBlock()->openEditContactInfo();
44+
$nameInEdit = $customerAccountEdit->getAccountInfoForm()->getFirstName()
45+
. " " . $customerAccountEdit->getAccountInfoForm()->getLastName();
46+
\PHPUnit_Framework_Assert::assertTrue(
47+
$nameInEdit == $customerName,
48+
'Customer name on Account info tab is not matching the fixture.'
49+
);
50+
}
51+
52+
/**
53+
* String representation of success assert.
54+
*
55+
* @return string
56+
*/
57+
public function toString()
58+
{
59+
return 'Customer name in Contact information block and Account info is correct.';
60+
}
61+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
/**
4+
* Copyright © 2016 Magento. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/pages.xsd">
9+
<page name="CustomerAccountAddress" mca="customer/address" module="Magento_Customer">
10+
<block name="titleBlock" class="Magento\Theme\Test\Block\Html\Title" locator=".page-title-wrapper" strategy="css selector" />
11+
<block name="accountMenuBlock" class="Magento\Customer\Test\Block\Account\Links" locator=".nav.items" strategy="css selector" />
12+
<block name="additionalAddressBlock" class="Magento\Customer\Test\Block\Account\AddressesAdditional" locator=".block-addresses-list" strategy="css selector" />
13+
<block name="defaultAddressBlock" class="Magento\Customer\Test\Block\Account\AddressesDefault" locator=".block-addresses-default" strategy="css selector" />
14+
</page>
15+
</config>

0 commit comments

Comments
 (0)