Skip to content

Commit d206d99

Browse files
committed
MTA-3253: Customer: Extend update customer group test
1 parent ee505e9 commit d206d99

File tree

6 files changed

+50
-46
lines changed

6 files changed

+50
-46
lines changed

dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Group/Edit/Form.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,29 @@
66

77
namespace Magento\Customer\Test\Block\Adminhtml\Group\Edit;
88

9+
use Magento\Mtf\Client\Locator;
10+
911
/**
1012
* Customer group edit form.
1113
*/
1214
class Form extends \Magento\Mtf\Block\Form
1315
{
1416
/**
15-
*
17+
* Check if field exists and is disabled.
1618
*
1719
* @param string $field
1820
* @return bool
21+
* @throws \Exception
1922
*/
2023
public function isFieldDisabled($field)
2124
{
22-
return $this->_rootElement->find($this->mapping[$field]['selector'])->isDisabled();
25+
if (!isset($this->mapping[$field])) {
26+
throw new \Exception("Cannot find field $field. Check for field mapping in " . self::class);
27+
}
28+
$disabledField = $this->mapping[$field]['selector'];
29+
$strategy = isset($this->mapping[$field]['strategy'])
30+
? $this->mapping[$field]['strategy']
31+
: Locator::SELECTOR_CSS;
32+
return $this->_rootElement->find($disabledField, $strategy)->isDisabled();
2333
}
2434
}

dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertGroupNotAvailableInField.php renamed to dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerGroupFieldDisabled.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,28 @@
88

99
use Magento\Customer\Test\Fixture\CustomerGroup;
1010
use Magento\Mtf\Constraint\AbstractConstraint;
11-
use Magento\Customer\Test\Page\Adminhtml\CustomerGroupIndex;
11+
use Magento\Customer\Test\Page\Adminhtml\CustomerGroupEdit;
1212

1313
/**
1414
* Assert that group field is not available.
1515
*/
16-
class AssertGroupNotAvailableInField extends AbstractConstraint
16+
class AssertCustomerGroupFieldDisabled extends AbstractConstraint
1717
{
1818
/**
1919
* Assert that customer group field is not available.
2020
*
21-
* @param CustomerGroupIndex $customerGroupIndex
22-
* @param CustomerGroup $customerGroup
21+
* @param CustomerGroupEdit $customerGroupEdit
2322
* @param array $disabledFields
2423
* @return void
2524
*/
2625
public function processAssert(
27-
CustomerGroupIndex $customerGroupIndex,
28-
CustomerGroup $customerGroup,
26+
CustomerGroupEdit $customerGroupEdit,
2927
array $disabledFields
3028
) {
3129
foreach ($disabledFields as $field) {
3230
\PHPUnit_Framework_Assert::assertTrue(
33-
$customerGroupIndex->getPageMainForm()->isFieldDisabled($field),
34-
"Field for group {$customerGroup->getCustomerGroupCode()} is not disabled."
31+
$customerGroupEdit->getPageMainForm()->isFieldDisabled($field),
32+
"Field $field is not disabled."
3533
);
3634
}
3735
}
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="CustomerGroupEdit" area="Adminhtml" mca="customer/group/edit" module="Magento_Customer">
10+
<block name="pageMainActions" class="Magento\Backend\Test\Block\FormPageActions" locator=".page-main-actions" strategy="css selector" />
11+
<block name="pageMainForm" class="Magento\Customer\Test\Block\Adminhtml\Group\Edit\Form" locator="[id='page:main-container']" strategy="css selector" />
12+
<block name="messagesBlock" class="Magento\Backend\Test\Block\Messages" locator="#messages" strategy="css selector" />
13+
<block name="modalBlock" class="Magento\Ui\Test\Block\Adminhtml\Modal" locator="._show[data-role=modal]" strategy="css selector" />
14+
</page>
15+
</config>

dev/tests/functional/tests/app/Magento/Customer/Test/Page/Adminhtml/CustomerGroupIndex.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,5 @@
1010
<block name="messagesBlock" class="Magento\Backend\Test\Block\Messages" locator="#messages .messages" strategy="css selector"/>
1111
<block name="gridPageActions" class="Magento\Backend\Test\Block\GridPageActions" locator=".page-main-actions" strategy="css selector"/>
1212
<block name="customerGroupGrid" class="Magento\Customer\Test\Block\Adminhtml\Group\CustomerGroupGrid" locator="#customerGroupGrid" strategy="css selector"/>
13-
<block name="pageMainForm" class="Magento\Customer\Test\Block\Adminhtml\Group\Edit\Form" locator="[id='page:main-container']" strategy="css selector"/>
1413
</page>
1514
</config>

dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/GroupNotAvailableInFieldTest.php renamed to dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/VerifyDisabledCustomerGroupFieldTest.php

Lines changed: 14 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,73 +8,55 @@
88

99
use Magento\Customer\Test\Fixture\CustomerGroup;
1010
use Magento\Customer\Test\Page\Adminhtml\CustomerGroupIndex;
11-
use Magento\Customer\Test\Page\Adminhtml\CustomerGroupNew;
1211
use Magento\Mtf\TestCase\Injectable;
1312

1413
/**
15-
* Test Creation for Update Customer Group Entity
16-
*
17-
* Test Flow:
18-
* Preconditions:
19-
* 1. Customer Group is created
2014
* Steps:
21-
* 1. Log in to backend as admin user
22-
* 2. Navigate to Stores > Other Settings > Customer Groups
23-
* 3. Select Customer Group from grid
24-
* 4. Perform all assertions
15+
* 1. Login to backend as admin user.
16+
* 2. Navigate to Stores > Other Settings > Customer Groups.
17+
* 3. Select system Customer Group specified in data set from grid.
18+
* 4. Perform all assertions.
2519
*
2620
* @group Customer_Groups_(CS)
27-
* @ZephyrId
21+
* @ZephyrId MAGETWO-52481
2822
*/
29-
class GroupNotAvailableInFieldTest extends Injectable
23+
class VerifyDisabledCustomerGroupFieldTest extends Injectable
3024
{
3125
/* tags */
3226
const MVP = 'yes';
3327
const DOMAIN = 'CS';
3428
/* end tags */
3529

3630
/**
37-
* Page CustomerGroupIndex
31+
* Page CustomerGroupIndex.
3832
*
3933
* @var CustomerGroupIndex
4034
*/
4135
protected $customerGroupIndex;
4236

4337
/**
44-
* Page CustomerGroupNew
45-
*
46-
* @var CustomerGroupNew
47-
*/
48-
protected $customerGroupNew;
49-
50-
/**
51-
* Injection data
38+
* Injection data.
5239
*
5340
* @param CustomerGroupIndex $customerGroupIndex
54-
* @param CustomerGroupNew $customerGroupNew
5541
* @return void
5642
*/
57-
public function __inject(
58-
CustomerGroupIndex $customerGroupIndex,
59-
CustomerGroupNew $customerGroupNew
60-
) {
43+
public function __inject(CustomerGroupIndex $customerGroupIndex)
44+
{
6145
$this->customerGroupIndex = $customerGroupIndex;
62-
$this->customerGroupNew = $customerGroupNew;
6346
}
6447

6548
/**
66-
* Check unavailable field in Customer Group
49+
* Check unavailable field in Customer Group.
6750
*
6851
* @param CustomerGroup $customerGroup
6952
* @return void
7053
*/
71-
public function test(
72-
CustomerGroup $customerGroup
73-
) {
54+
public function test(CustomerGroup $customerGroup)
55+
{
7456
$filter = ['code' => $customerGroup->getCustomerGroupCode()];
7557

7658
// Steps
7759
$this->customerGroupIndex->open();
7860
$this->customerGroupIndex->getCustomerGroupGrid()->searchAndOpen($filter);
7961
}
80-
}
62+
}

dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/GroupNotAvailableInFieldTest.xml renamed to dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/VerifyDisabledCustomerGroupFieldTest.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
*/
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd">
9-
<testCase name="Magento\Customer\Test\TestCase\GroupNotAvailableInFieldTest" summary="Group not available">
10-
<variation name="GroupNotAvailableInFieldTestVariation1">
9+
<testCase name="Magento\Customer\Test\TestCase\VerifyDisabledCustomerGroupFieldTest" summary="Check that field is disabled in system Customer Group" ticketId="MAGETWO-52481">
10+
<variation name="VerifyDisabledCustomerGroupField1" summary="Checks that customer_group_code field is disabled in NOT LOGGED IN Customer Group">
1111
<data name="customerGroup/dataset" xsi:type="string">NOT_LOGGED_IN</data>
1212
<data name="disabledFields" xsi:type="array">
1313
<item name="0" xsi:type="string">customer_group_code</item>
1414
</data>
15-
<constraint name="Magento\Customer\Test\Constraint\AssertGroupNotAvailableInField" />
15+
<constraint name="Magento\Customer\Test\Constraint\AssertCustomerGroupFieldDisabled" />
1616
</variation>
1717
</testCase>
1818
</config>

0 commit comments

Comments
 (0)