Skip to content

Commit 8d0a729

Browse files
authored
Merge pull request #1352 from magento-dragons/DRAGONS-PR-JULY
Fixed issues: MAGETWO-70878: Category position does not save MAGETWO-67066: Changing the values and forms for system customer attribute
2 parents e2b4d6b + 58bc916 commit 8d0a729

File tree

5 files changed

+196
-2
lines changed

5 files changed

+196
-2
lines changed

app/code/Magento/Catalog/view/adminhtml/templates/catalog/category/tree.phtml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@
5959
}
6060
};
6161

62+
var treeRoot = '#tree-div';
63+
6264
/**
6365
* Fix ext compatibility with prototype 1.6
6466
*/
@@ -491,7 +493,7 @@
491493
if (data.error) {
492494
reRenderTree();
493495
} else {
494-
$(obj.tree.container.dom).trigger('categoryMove.tree');
496+
$(treeRoot).trigger('categoryMove.tree');
495497
}
496498
$('.page-main-actions').next('.messages').remove();
497499
$('.page-main-actions').next('#messages').remove();

dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Category/Tree.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public function isCategoryVisible(Category $category)
169169
*/
170170
public function assignCategory($parentCategoryName, $childCategoryName)
171171
{
172-
$this->_rootElement->find(sprintf($this->categoryInTree, $childCategoryName), Locator::SELECTOR_XPATH)->click();
172+
$this->_rootElement->find(sprintf($this->categoryInTree, $childCategoryName), Locator::SELECTOR_XPATH)->hover();
173173
$this->getTemplateBlock()->waitLoader();
174174
$targetElement = $this->_rootElement->find(
175175
sprintf($this->categoryInTree, $parentCategoryName),
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Catalog\Test\TestCase\Category;
8+
9+
use Magento\Catalog\Test\Fixture\Category;
10+
use Magento\Catalog\Test\Page\Adminhtml\CatalogCategoryEdit;
11+
use Magento\Catalog\Test\Page\Adminhtml\CatalogCategoryIndex;
12+
use Magento\Mtf\Fixture\FixtureFactory;
13+
use Magento\Mtf\TestCase\Injectable;
14+
15+
/**
16+
* Precondition:
17+
* 1. Categories are created
18+
*
19+
* Test Flow:
20+
* 1. Log in to Backend
21+
* 2. Navigate to the Products>Categories
22+
* 3. Select SubCategory
23+
* 4. Drag'n'Drop SubCategory
24+
* 5. Dismiss alert
25+
* 6. Drag'n'Drop SubCategory
26+
* 7. Accept alert
27+
* 8. Save category
28+
* 9. Verify category
29+
*
30+
* @group Category_Management
31+
* @ZephyrId MAGETWO-27319
32+
*/
33+
class AdvancedMoveCategoryEntityTest extends Injectable
34+
{
35+
/* tags */
36+
const MVP = 'no';
37+
/* end tags */
38+
39+
/**
40+
* CatalogCategoryIndex page.
41+
*
42+
* @var CatalogCategoryIndex
43+
*/
44+
private $catalogCategoryIndex;
45+
46+
/**
47+
* CatalogCategoryEdit page.
48+
*
49+
* @var CatalogCategoryEdit
50+
*/
51+
private $catalogCategoryEdit;
52+
53+
/**
54+
* Factory for fixtures.
55+
*
56+
* @var FixtureFactory
57+
*/
58+
private $fixtureFactory;
59+
60+
/**
61+
* Inject page end prepare default category.
62+
*
63+
* @param CatalogCategoryIndex $catalogCategoryIndex
64+
* @param CatalogCategoryEdit $catalogCategoryEdit
65+
* @param FixtureFactory $fixtureFactory
66+
* @return void
67+
*/
68+
public function __inject(
69+
CatalogCategoryIndex $catalogCategoryIndex,
70+
CatalogCategoryEdit $catalogCategoryEdit,
71+
FixtureFactory $fixtureFactory
72+
) {
73+
$this->catalogCategoryIndex = $catalogCategoryIndex;
74+
$this->catalogCategoryEdit = $catalogCategoryEdit;
75+
$this->fixtureFactory = $fixtureFactory;
76+
}
77+
78+
/**
79+
* Runs test.
80+
*
81+
* @param Category $childCategory
82+
* @param Category $parentCategory
83+
* @param int|null $moveLevel
84+
* @return array
85+
*/
86+
public function test(
87+
Category $childCategory,
88+
Category $parentCategory,
89+
$moveLevel = null
90+
) {
91+
// Preconditions:
92+
$parentCategory->persist();
93+
$childCategory->persist();
94+
$resultCategory = $childCategory;
95+
96+
if (!empty($moveLevel)) {
97+
for ($nestingIterator = 1; $nestingIterator < $moveLevel; $nestingIterator++) {
98+
$childCategory = $childCategory->getDataFieldConfig('parent_id')['source']->getParentCategory();
99+
}
100+
$resultCategory = $this->getMovedCategoryTree($resultCategory, $parentCategory, $childCategory);
101+
}
102+
103+
// Steps:
104+
$this->catalogCategoryIndex->open();
105+
$this->catalogCategoryIndex->getTreeCategories()->expandAllCategories();
106+
$this->catalogCategoryIndex->getTreeCategories()->selectCategory($childCategory);
107+
$this->catalogCategoryIndex->getTreeCategories()->assignCategory(
108+
$parentCategory->getName(),
109+
$childCategory->getName()
110+
);
111+
$this->catalogCategoryEdit->getModalBlock()->dismissWarning();
112+
113+
$this->catalogCategoryIndex->getTreeCategories()->assignCategory(
114+
$parentCategory->getName(),
115+
$childCategory->getName()
116+
);
117+
$this->catalogCategoryEdit->getModalBlock()->acceptWarning();
118+
$this->catalogCategoryEdit->getFormPageActions()->save();
119+
120+
return [
121+
'category' => $resultCategory,
122+
'parentCategory' => $parentCategory,
123+
'childCategory' => $childCategory,
124+
];
125+
}
126+
127+
/**
128+
* Get moved category tree.
129+
*
130+
* @param Category $movedCategory
131+
* @param Category $parentCategory
132+
* @param Category $childCategory
133+
* @return Category
134+
*/
135+
public function getMovedCategoryTree(Category $movedCategory, Category $parentCategory, Category $childCategory)
136+
{
137+
$bottomChildCategory = [];
138+
while ($movedCategory->getName() != $childCategory->getName()) {
139+
$bottomChildCategory[] = $movedCategory->getData();
140+
$movedCategory = $movedCategory->getDataFieldConfig('parent_id')['source']->getParentCategory();
141+
}
142+
$bottomChildCategory[] = $movedCategory->getData();
143+
144+
$newCategory = $parentCategory;
145+
for ($i = count($bottomChildCategory) - 1; $i >= 0; $i--) {
146+
unset($bottomChildCategory[$i]['parent_id']);
147+
$bottomChildCategory[$i]['parent_id']['source'] = $newCategory;
148+
$newCategory = $this->fixtureFactory->createByCode(
149+
'category',
150+
['data' => $bottomChildCategory[$i]]
151+
);
152+
}
153+
154+
return $newCategory;
155+
}
156+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. 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\Catalog\Test\TestCase\Category\AdvancedMoveCategoryEntityTest" summary="Move category from one to another" ticketId="MAGETWO-27319">
10+
<variation name="AdvancedMoveCategoryEntityTestVariation1">
11+
<data name="childCategory/dataset" xsi:type="string">three_nested_categories</data>
12+
<data name="parentCategory/dataset" xsi:type="string">default</data>
13+
<data name="moveLevel" xsi:type="number">1</data>
14+
<constraint name="Magento\UrlRewrite\Test\Constraint\AssertUrlRewriteCategoryInGrid" />
15+
<constraint name="Magento\Catalog\Test\Constraint\AssertCategoryBreadcrumbs" />
16+
</variation>
17+
</testCase>
18+
</config>

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ class Edit extends Form
3030
*/
3131
protected $vatFieldId = 'vat_id';
3232

33+
/**
34+
* Locator for address simple (input, textarea, not multiple fields) attribute
35+
*
36+
* @var string
37+
*/
38+
private $addressSimpleAttribute = "[name='%s']";
39+
3340
/**
3441
* Edit customer address
3542
*
@@ -77,4 +84,15 @@ protected function dataMapping(array $fields = null, $parent = null)
7784
}
7885
return parent::dataMapping($fields, $parent);
7986
}
87+
88+
/**
89+
* Check if Customer Address Simple(input, textarea, not multiple fields) Attribute visible
90+
*
91+
* @param string $attributeCode
92+
* @return bool
93+
*/
94+
public function isAddressSimpleAttributeVisible($attributeCode)
95+
{
96+
return $this->_rootElement->find(sprintf($this->addressSimpleAttribute, $attributeCode))->isVisible();
97+
}
8098
}

0 commit comments

Comments
 (0)