Skip to content

Commit f181910

Browse files
committed
MTA-3254: Extend delete customer group test
1 parent 441fed2 commit f181910

15 files changed

+457
-30
lines changed

dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
<field name="tax_class_id" is_required="0" group="product-details" source="Magento\Catalog\Test\Fixture\Product\TaxClass" />
6565
<field name="thumbnail" is_required="0" />
6666
<field name="thumbnail_label" is_required="0" />
67-
<field name="tier_price" is_required="0" group="advanced-pricing" repository="Magento\Catalog\Test\Repository\Product\TierPrice" />
67+
<field name="tier_price" is_required="0" group="advanced-pricing" source="Magento\Catalog\Test\Fixture\Product\TierPrice" repository="Magento\Catalog\Test\Repository\Product\TierPrice" />
6868
<field name="updated_at" is_required="1" />
6969
<field name="url_key" is_required="0" group="search-engine-optimization" />
7070
<field name="url_path" is_required="0" />
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Catalog\Test\Fixture\Product;
8+
9+
use Magento\Mtf\Fixture\DataSource;
10+
use Magento\Mtf\Fixture\FixtureFactory;
11+
use Magento\Customer\Test\Fixture\CustomerGroup;
12+
use Magento\Mtf\Repository\RepositoryFactory;
13+
14+
/**
15+
*
16+
*/
17+
class TierPrice extends DataSource
18+
{
19+
/**
20+
* Customer group fixture array.
21+
*
22+
* @var array
23+
*/
24+
private $customerGroups;
25+
26+
/**
27+
* @constructor
28+
* @param RepositoryFactory $repositoryFactory
29+
* @param FixtureFactory $fixtureFactory
30+
* @param array $params
31+
* @param array $data
32+
* @throws \Exception
33+
*/
34+
public function __construct(
35+
RepositoryFactory $repositoryFactory,
36+
FixtureFactory $fixtureFactory,
37+
array $params,
38+
$data = []
39+
) {
40+
$this->params = $params;
41+
if (!isset($data['dataset'])) {
42+
throw new \Exception("Data must be set");
43+
}
44+
$this->data = $repositoryFactory->get($this->params['repository'])->get($data['dataset']);
45+
foreach ($this->data as $key => $item) {
46+
/** @var CustomerGroup $customerGroup */
47+
$customerGroup = $fixtureFactory->createByCode(
48+
'customerGroup',
49+
['dataset' => $item['customer_group']['dataset']]
50+
);
51+
if (!$customerGroup->hasData('customer_group_id')) {
52+
$customerGroup->persist();
53+
}
54+
$this->data[$key]['customer_group'] = $customerGroup->getCustomerGroupCode();
55+
$this->customerGroups[$key] = $customerGroup;
56+
}
57+
}
58+
59+
/**
60+
* Return customer group fixture.
61+
*
62+
* @return array
63+
*/
64+
public function getCustomerGroups()
65+
{
66+
return $this->customerGroups;
67+
}
68+
}

dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductSimple/Curl.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,7 @@ class Curl extends AbstractCurl implements CatalogProductSimpleInterface
138138
]
139139
],
140140
'customer_group' => [
141-
'name' => 'cust_group',
142-
'data' => [
143-
'ALL GROUPS' => 32000,
144-
'NOT LOGGED IN' => 0,
145-
'General' => 1
146-
]
141+
'name' => 'cust_group'
147142
]
148143
];
149144

@@ -455,9 +450,15 @@ protected function prepareAdvancedPricing()
455450
*/
456451
protected function preparePriceFields(array $fields)
457452
{
458-
foreach ($fields as &$field) {
453+
foreach ($fields as $priceKey => &$field) {
459454
foreach ($this->priceData as $key => $data) {
460-
$field[$data['name']] = $this->priceData[$key]['data'][$field[$key]];
455+
if ($data['name'] == 'cust_group') {
456+
$field[$data['name']] =
457+
$this->fixture->getDataFieldConfig('tier_price')['source']->
458+
getCustomerGroups()[$priceKey]->getCustomerGroupId();
459+
} else {
460+
$field[$data['name']] = $this->priceData[$key]['data'][$field[$key]];
461+
}
461462
unset($field[$key]);
462463
}
463464
$field['delete'] = '';

dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductSimple.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@
651651
<item name="is_in_stock" xsi:type="string">In Stock</item>
652652
</field>
653653
<field name="tier_price" xsi:type="array">
654-
<item name="dataset" xsi:type="string">default</item>
654+
<item name="dataset" xsi:type="string">general</item>
655655
</field>
656656
<field name="category_ids" xsi:type="array">
657657
<item name="dataset" xsi:type="string">default_subcategory</item>

dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/Product/TierPrice.xml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,17 @@
1212
<item name="price" xsi:type="string">15</item>
1313
<item name="website" xsi:type="string">All Websites [USD]</item>
1414
<item name="price_qty" xsi:type="string">3</item>
15-
<item name="customer_group" xsi:type="string">ALL GROUPS</item>
15+
<item name="customer_group" xsi:type="array">
16+
<item name="dataset" xsi:type="string">ALL_GROUPS</item>
17+
</item>
1618
</field>
1719
<field name="1" xsi:type="array">
1820
<item name="price" xsi:type="string">24</item>
1921
<item name="website" xsi:type="string">All Websites [USD]</item>
2022
<item name="price_qty" xsi:type="string">15</item>
21-
<item name="customer_group" xsi:type="string">ALL GROUPS</item>
23+
<item name="customer_group" xsi:type="array">
24+
<item name="dataset" xsi:type="string">ALL_GROUPS</item>
25+
</item>
2226
</field>
2327
</dataset>
2428

@@ -27,7 +31,9 @@
2731
<item name="price" xsi:type="string">90</item>
2832
<item name="website" xsi:type="string">All Websites [USD]</item>
2933
<item name="price_qty" xsi:type="string">2</item>
30-
<item name="customer_group" xsi:type="string">ALL GROUPS</item>
34+
<item name="customer_group" xsi:type="array">
35+
<item name="dataset" xsi:type="string">ALL_GROUPS</item>
36+
</item>
3137
</field>
3238
</dataset>
3339

@@ -36,7 +42,9 @@
3642
<item name="price" xsi:type="string">80</item>
3743
<item name="website" xsi:type="string">All Websites [USD]</item>
3844
<item name="price_qty" xsi:type="string">2</item>
39-
<item name="customer_group" xsi:type="string">General</item>
45+
<item name="customer_group" xsi:type="array">
46+
<item name="dataset" xsi:type="string">General</item>
47+
</item>
4048
</field>
4149
</dataset>
4250
</repository>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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\Customer\Test\Fixture\Customer;
11+
use Magento\Customer\Test\Page\Adminhtml\CustomerIndex;
12+
use Magento\Customer\Test\Page\Adminhtml\CustomerIndexNew;
13+
use Magento\Mtf\Constraint\AbstractConstraint;
14+
15+
/**
16+
* Class AssertCustomerGroupChangedToDefaultOnCustomerForm.
17+
*/
18+
class AssertCustomerGroupChangedToDefaultOnCustomerForm extends AbstractConstraint
19+
{
20+
/**
21+
* Assert that customer group is General on account information page.
22+
*
23+
* @param Customer $customer
24+
* @param CustomerGroup $customerGroup
25+
* @param CustomerIndexNew $customerIndexNew
26+
* @param CustomerIndex $customerIndex
27+
* @return void
28+
*/
29+
public function processAssert(
30+
Customer $customer,
31+
CustomerGroup $customerGroup,
32+
CustomerIndexNew $customerIndexNew,
33+
CustomerIndex $customerIndex
34+
) {
35+
$filter = ['email' => $customer->getEmail()];
36+
$customerIndex->open();
37+
$customerIndex->getCustomerGridBlock()->searchAndOpen($filter);
38+
$customerFormData = $customerIndexNew->getCustomerForm()->getData();
39+
\PHPUnit_Framework_Assert::assertTrue(
40+
$customerFormData['group_id'] == "General",
41+
"Customer group {$customerGroup->getCustomerGroupCode()} not set to General after group was deleted."
42+
);
43+
}
44+
45+
/**
46+
* Success assert of customer group set to default on account information page.
47+
*
48+
* @return string
49+
*/
50+
public function toString()
51+
{
52+
return 'Customer group is set to default on account information page.';
53+
}
54+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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\SalesRule\Test\Block\Adminhtml\Promo\Quote\Edit\Section\RuleInformation;
12+
use Magento\SalesRule\Test\Page\Adminhtml\PromoQuoteIndex;
13+
use Magento\SalesRule\Test\Page\Adminhtml\PromoQuoteNew;
14+
15+
/**
16+
* Class AssertCustomerGroupNotOnCartPriceRuleForm.
17+
*/
18+
class AssertCustomerGroupNotOnCartPriceRuleForm extends AbstractConstraint
19+
{
20+
/**
21+
* Assert that customer group is not on cart price rule page.
22+
*
23+
* @param PromoQuoteIndex $promoQuoteIndex
24+
* @param PromoQuoteNew $promoQuoteNew
25+
* @param CustomerGroup $customerGroup
26+
* @return void
27+
*/
28+
public function processAssert(
29+
PromoQuoteIndex $promoQuoteIndex,
30+
PromoQuoteNew $promoQuoteNew,
31+
CustomerGroup $customerGroup
32+
) {
33+
$promoQuoteIndex->open();
34+
$promoQuoteIndex->getGridPageActions()->addNew();
35+
$promoQuoteNew->getSalesRuleForm()->openSection('rule_information');
36+
37+
/** @var RuleInformation $ruleInformationTab */
38+
$ruleInformationTab = $promoQuoteNew->getSalesRuleForm()->getSection('rule_information');
39+
\PHPUnit_Framework_Assert::assertFalse(
40+
$ruleInformationTab->isVisibleCustomerGroup($customerGroup),
41+
"Customer group {$customerGroup->getCustomerGroupCode()} is still in cart price rule page."
42+
);
43+
}
44+
45+
/**
46+
* Success assert of customer group not on cart price rule page.
47+
*
48+
* @return string
49+
*/
50+
public function toString()
51+
{
52+
return 'Customer group is not on cart price rule page.';
53+
}
54+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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\CatalogRule\Test\Page\Adminhtml\CatalogRuleIndex;
10+
use Magento\CatalogRule\Test\Page\Adminhtml\CatalogRuleNew;
11+
use Magento\Customer\Test\Fixture\CustomerGroup;
12+
use Magento\Mtf\Constraint\AbstractConstraint;
13+
use Magento\CatalogRule\Test\Block\Adminhtml\Promo\Catalog\Edit\Section\RuleInformation;
14+
15+
/**
16+
* Class AssertCustomerGroupNotOnCatalogPriceRuleForm.
17+
*/
18+
class AssertCustomerGroupNotOnCatalogPriceRuleForm extends AbstractConstraint
19+
{
20+
/**
21+
* Assert that customer group is not on catalog price rule page.
22+
*
23+
* @param CatalogRuleIndex $catalogRuleIndex
24+
* @param CatalogRuleNew $catalogRuleNew
25+
* @param CustomerGroup $customerGroup
26+
* @return void
27+
*/
28+
public function processAssert(
29+
CatalogRuleIndex $catalogRuleIndex,
30+
CatalogRuleNew $catalogRuleNew,
31+
CustomerGroup $customerGroup
32+
) {
33+
$catalogRuleIndex->open();
34+
$catalogRuleIndex->getGridPageActions()->addNew();
35+
$catalogRuleNew->getEditForm()->openSection('rule_information');
36+
37+
/** @var RuleInformation $ruleInformationSection */
38+
$ruleInformationSection = $catalogRuleNew->getEditForm()->getSection('rule_information');
39+
\PHPUnit_Framework_Assert::assertFalse(
40+
$ruleInformationSection->isVisibleCustomerGroup($customerGroup),
41+
"Customer group {$customerGroup->getCustomerGroupCode()} is still in catalog price rule page."
42+
);
43+
}
44+
45+
/**
46+
* Success assert of customer group absent on catalog price rule page.
47+
*
48+
* @return string
49+
*/
50+
public function toString()
51+
{
52+
return 'Customer group is not on catalog price rule page.';
53+
}
54+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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\Catalog\Test\Block\Adminhtml\Product\Edit\Section\AdvancedPricing;
10+
use Magento\Catalog\Test\Page\Adminhtml\CatalogProductIndex;
11+
use Magento\Catalog\Test\Page\Adminhtml\CatalogProductNew;
12+
use Magento\Customer\Test\Fixture\CustomerGroup;
13+
use Magento\Mtf\Constraint\AbstractConstraint;
14+
15+
/**
16+
* Class AssertCustomerGroupNotOnProductForm.
17+
*/
18+
class AssertCustomerGroupNotOnProductForm extends AbstractConstraint
19+
{
20+
/**
21+
* Assert that customer group not on product page.
22+
*
23+
* @param CatalogProductIndex $catalogProductIndex
24+
* @param CatalogProductNew $catalogProductNew
25+
* @param CustomerGroup $customerGroup
26+
* @return void
27+
*/
28+
public function processAssert(
29+
CatalogProductIndex $catalogProductIndex,
30+
CatalogProductNew $catalogProductNew,
31+
CustomerGroup $customerGroup
32+
) {
33+
$catalogProductIndex->open();
34+
$catalogProductIndex->getGridPageActionBlock()->addProduct();
35+
$catalogProductNew->getProductForm()->openSection('advanced-pricing');
36+
37+
/** @var AdvancedPricing $advancedPricingTab */
38+
$advancedPricingTab = $catalogProductNew->getProductForm()->getSection('advanced-pricing');
39+
\PHPUnit_Framework_Assert::assertFalse(
40+
$advancedPricingTab->getTierPriceForm()->isVisibleCustomerGroup($customerGroup),
41+
"Customer group {$customerGroup->getCustomerGroupCode()} is still in tier price form on product page."
42+
);
43+
}
44+
45+
/**
46+
* Success assert of customer group absent on product page.
47+
*
48+
* @return string
49+
*/
50+
public function toString()
51+
{
52+
return 'Customer group not on product page.';
53+
}
54+
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ public function processAssert(
4040
$ruleInformationSection->isVisibleCustomerGroup($customerGroup),
4141
"Customer group {$customerGroup->getCustomerGroupCode()} not in catalog price rule page."
4242
);
43-
4443
}
4544

4645
/**

0 commit comments

Comments
 (0)