Skip to content

Commit ee505e9

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

File tree

6 files changed

+160
-1
lines changed

6 files changed

+160
-1
lines changed

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,14 @@
1111
*/
1212
class Form extends \Magento\Mtf\Block\Form
1313
{
14-
//
14+
/**
15+
*
16+
*
17+
* @param string $field
18+
* @return bool
19+
*/
20+
public function isFieldDisabled($field)
21+
{
22+
return $this->_rootElement->find($this->mapping[$field]['selector'])->isDisabled();
23+
}
1524
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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\CustomerGroup;
10+
use Magento\Mtf\Constraint\AbstractConstraint;
11+
use Magento\Customer\Test\Page\Adminhtml\CustomerGroupIndex;
12+
13+
/**
14+
* Assert that group field is not available.
15+
*/
16+
class AssertGroupNotAvailableInField extends AbstractConstraint
17+
{
18+
/**
19+
* Assert that customer group field is not available.
20+
*
21+
* @param CustomerGroupIndex $customerGroupIndex
22+
* @param CustomerGroup $customerGroup
23+
* @param array $disabledFields
24+
* @return void
25+
*/
26+
public function processAssert(
27+
CustomerGroupIndex $customerGroupIndex,
28+
CustomerGroup $customerGroup,
29+
array $disabledFields
30+
) {
31+
foreach ($disabledFields as $field) {
32+
\PHPUnit_Framework_Assert::assertTrue(
33+
$customerGroupIndex->getPageMainForm()->isFieldDisabled($field),
34+
"Field for group {$customerGroup->getCustomerGroupCode()} is not disabled."
35+
);
36+
}
37+
}
38+
39+
/**
40+
* Success assert of customer group field not available.
41+
*
42+
* @return string
43+
*/
44+
public function toString()
45+
{
46+
return 'Customer group field is not available.';
47+
}
48+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@
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"/>
1314
</page>
1415
</config>
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Customer\Test\TestCase;
8+
9+
use Magento\Customer\Test\Fixture\CustomerGroup;
10+
use Magento\Customer\Test\Page\Adminhtml\CustomerGroupIndex;
11+
use Magento\Customer\Test\Page\Adminhtml\CustomerGroupNew;
12+
use Magento\Mtf\TestCase\Injectable;
13+
14+
/**
15+
* Test Creation for Update Customer Group Entity
16+
*
17+
* Test Flow:
18+
* Preconditions:
19+
* 1. Customer Group is created
20+
* 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
25+
*
26+
* @group Customer_Groups_(CS)
27+
* @ZephyrId
28+
*/
29+
class GroupNotAvailableInFieldTest extends Injectable
30+
{
31+
/* tags */
32+
const MVP = 'yes';
33+
const DOMAIN = 'CS';
34+
/* end tags */
35+
36+
/**
37+
* Page CustomerGroupIndex
38+
*
39+
* @var CustomerGroupIndex
40+
*/
41+
protected $customerGroupIndex;
42+
43+
/**
44+
* Page CustomerGroupNew
45+
*
46+
* @var CustomerGroupNew
47+
*/
48+
protected $customerGroupNew;
49+
50+
/**
51+
* Injection data
52+
*
53+
* @param CustomerGroupIndex $customerGroupIndex
54+
* @param CustomerGroupNew $customerGroupNew
55+
* @return void
56+
*/
57+
public function __inject(
58+
CustomerGroupIndex $customerGroupIndex,
59+
CustomerGroupNew $customerGroupNew
60+
) {
61+
$this->customerGroupIndex = $customerGroupIndex;
62+
$this->customerGroupNew = $customerGroupNew;
63+
}
64+
65+
/**
66+
* Check unavailable field in Customer Group
67+
*
68+
* @param CustomerGroup $customerGroup
69+
* @return void
70+
*/
71+
public function test(
72+
CustomerGroup $customerGroup
73+
) {
74+
$filter = ['code' => $customerGroup->getCustomerGroupCode()];
75+
76+
// Steps
77+
$this->customerGroupIndex->open();
78+
$this->customerGroupIndex->getCustomerGroupGrid()->searchAndOpen($filter);
79+
}
80+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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/variations.xsd">
9+
<testCase name="Magento\Customer\Test\TestCase\GroupNotAvailableInFieldTest" summary="Group not available">
10+
<variation name="GroupNotAvailableInFieldTestVariation1">
11+
<data name="customerGroup/dataset" xsi:type="string">NOT_LOGGED_IN</data>
12+
<data name="disabledFields" xsi:type="array">
13+
<item name="0" xsi:type="string">customer_group_code</item>
14+
</data>
15+
<constraint name="Magento\Customer\Test\Constraint\AssertGroupNotAvailableInField" />
16+
</variation>
17+
</testCase>
18+
</config>

dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/UpdateCustomerGroupEntityTest.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@
3535
<constraint name="Magento\Customer\Test\Constraint\AssertCustomerGroupInGrid" />
3636
<constraint name="Magento\Customer\Test\Constraint\AssertCustomerGroupOnCustomerForm" />
3737
<constraint name="Magento\Customer\Test\Constraint\AssertCustomerGroupForm" />
38+
<constraint name="Magento\Customer\Test\Constraint\AssertCustomerGroupOnCartPriceRuleForm" />
39+
<constraint name="Magento\Customer\Test\Constraint\AssertCustomerGroupOnCatalogPriceRuleForm" />
40+
<constraint name="Magento\Customer\Test\Constraint\AssertCustomerGroupOnProductForm" />
3841
</variation>
3942
</testCase>
4043
</config>

0 commit comments

Comments
 (0)