Skip to content

Commit 846c193

Browse files
author
Vadim Zubovich
committed
MTO-95: PRs stabilization
- Product form filling issue fixed - Wrong parsing sort options issue fixed - The creation new category  implemented (MAGETWO-58108) - Issue tag added (MAGETWO-60635) - "to_maintain:yes" tag removed (MAGETWO-60635) - Added suppress warning annotation to skip static test fail related with a coupling between objects
1 parent 331b1e0 commit 846c193

File tree

3 files changed

+35
-11
lines changed

3 files changed

+35
-11
lines changed

dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/ProductForm.php

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@
1414
use Magento\Mtf\Client\Locator;
1515
use Magento\Mtf\Fixture\FixtureInterface;
1616
use Magento\Ui\Test\Block\Adminhtml\DataGrid;
17+
use Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Section\ProductDetails\NewCategoryIds;
1718

1819
/**
1920
* Product form on backend product page.
21+
*
22+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2023
*/
2124
class ProductForm extends FormSections
2225
{
@@ -48,6 +51,13 @@ class ProductForm extends FormSections
4851
*/
4952
protected $attributeBlock = '[data-index="%s"]';
5053

54+
/**
55+
* NewCategoryIds block selector.
56+
*
57+
* @var string
58+
*/
59+
protected $newCategoryModalForm = '.product_form_product_form_create_category_modal';
60+
5161
/**
5262
* Magento form loader.
5363
*
@@ -70,8 +80,6 @@ class ProductForm extends FormSections
7080
* @param FixtureInterface|null $category
7181
* @return $this
7282
* @throws \Exception
73-
*
74-
* @SuppressWarnings(PHPMD.NPathComplexity)
7583
*/
7684
public function fill(FixtureInterface $product, SimpleElement $element = null, FixtureInterface $category = null)
7785
{
@@ -88,9 +96,14 @@ public function fill(FixtureInterface $product, SimpleElement $element = null, F
8896
$this->callRender($typeId, 'fill', $renderArguments);
8997
} else {
9098
$sections = $this->getFixtureFieldsByContainers($product);
91-
99+
$category = $product->hasData('category_ids')
100+
? $product->getDataFieldConfig('category_ids')['source']->getCategories()[0] : $category;
92101
if ($category) {
93-
$sections['product-details']['category_ids']['value'] = $category->getName();
102+
if ((int)$category->getId()) {
103+
$sections['product-details']['category_ids']['value'] = $category->getName();
104+
} else {
105+
$this->getNewCategoryModalForm()->addNewCategory($category);
106+
}
94107
}
95108
$this->fillContainers($sections, $element);
96109
}
@@ -193,6 +206,19 @@ public function getAttributeForm()
193206
);
194207
}
195208

209+
/**
210+
* Get New Category Modal Form.
211+
*
212+
* @return NewCategoryIds
213+
*/
214+
public function getNewCategoryModalForm()
215+
{
216+
return $this->blockFactory->create(
217+
\Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Section\ProductDetails\NewCategoryIds::class,
218+
['element' => $this->browser->find($this->newCategoryModalForm)]
219+
);
220+
}
221+
196222
/**
197223
* Get attribute element.
198224
*

dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/ProductList/TopToolbar.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,11 @@ public function getSelectSortType()
3636
/**
3737
* Get all available method of sorting product
3838
*
39-
* @return array|string
39+
* @return array
4040
*/
4141
public function getSortType()
4242
{
4343
$content = $this->_rootElement->find($this->sorter)->getText();
44-
preg_match_all('/\w+\s?\w+/', $content, $matches);
45-
return $matches[0];
44+
return explode("\n", $content);
4645
}
4746
}

dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/CreateCategoryEntityTest.xml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<constraint name="Magento\Catalog\Test\Constraint\AssertCategoryForm" />
1717
</variation>
1818
<variation name="CreateCategoryEntityTestVariation2_RootCategory_AllFields">
19-
<data name="tag" xsi:type="string">to_maintain:yes</data>
19+
<data name="issue" xsi:type="string">MAGETWO-60635: [CE][Categories] Design update dates are incorrect after save</data>
2020
<data name="description" xsi:type="string">Create root category with all fields</data>
2121
<data name="addCategory" xsi:type="string">addRootCategory</data>
2222
<data name="category/data/is_active" xsi:type="string">Yes</data>
@@ -57,7 +57,7 @@
5757
<constraint name="Magento\Catalog\Test\Constraint\AssertCategoryPage" />
5858
</variation>
5959
<variation name="CreateCategoryEntityTestVariation4_Subcategory_AllFields">
60-
<data name="tag" xsi:type="string">to_maintain:yes</data>
60+
<data name="issue" xsi:type="string">MAGETWO-60635: [CE][Categories] Design update dates are incorrect after save</data>
6161
<data name="description" xsi:type="string">Create not anchor subcategory specifying all fields</data>
6262
<data name="addCategory" xsi:type="string">addSubcategory</data>
6363
<data name="category/data/parent_id/dataset" xsi:type="string">default_category</data>
@@ -94,7 +94,6 @@
9494
<constraint name="Magento\Catalog\Test\Constraint\AssertCategoryForAssignedProducts" />
9595
</variation>
9696
<variation name="CreateCategoryEntityTestVariation5_Anchor_MostOfFields">
97-
<data name="tag" xsi:type="string">to_maintain:yes</data>
9897
<data name="description" xsi:type="string">Create anchor subcategory with all fields</data>
9998
<data name="addCategory" xsi:type="string">addSubcategory</data>
10099
<data name="category/data/parent_id/dataset" xsi:type="string">default_category</data>
@@ -155,7 +154,7 @@
155154
<constraint name="Magento\Catalog\Test\Constraint\AssertCategoryForAssignedProducts" />
156155
</variation>
157156
<variation name="CreateCategoryEntityTestVariation9_ThreeNesting">
158-
<data name="tag" xsi:type="string">test_type:extended_acceptance_test, to_maintain:yes</data>
157+
<data name="tag" xsi:type="string">test_type:extended_acceptance_test</data>
159158
<data name="description" xsi:type="string">Create category with three nesting</data>
160159
<data name="addCategory" xsi:type="string">addSubcategory</data>
161160
<data name="category/data/parent_id/dataset" xsi:type="string">two_nested_categories</data>

0 commit comments

Comments
 (0)