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;
41 private $catalogCategoryIndex;
48 private $catalogCategoryEdit;
55 private $fixtureFactory;
66 CatalogCategoryIndex $catalogCategoryIndex,
67 CatalogCategoryEdit $catalogCategoryEdit,
68 FixtureFactory $fixtureFactory
70 $this->catalogCategoryIndex = $catalogCategoryIndex;
71 $this->catalogCategoryEdit = $catalogCategoryEdit;
72 $this->fixtureFactory = $fixtureFactory;
84 Category $childCategory,
85 Category $parentCategory,
89 $parentCategory->persist();
90 $childCategory->persist();
91 $resultCategory = $childCategory;
93 if (!empty($moveLevel)) {
94 for ($nestingIterator = 1; $nestingIterator < $moveLevel; $nestingIterator++) {
95 $childCategory = $childCategory->getDataFieldConfig(
'parent_id')[
'source']->getParentCategory();
101 $this->catalogCategoryIndex->open();
102 $this->catalogCategoryIndex->getTreeCategories()->expandAllCategories();
103 $this->catalogCategoryIndex->getTreeCategories()->assignCategory(
104 $parentCategory->getName(),
105 $childCategory->getName()
107 $this->catalogCategoryEdit->getModalBlock()->acceptWarning();
110 'category' => $resultCategory,
111 'parentCategory' => $parentCategory,
112 'childCategory' => $childCategory,
124 public function getMovedCategoryTree(Category $movedCategory, Category $parentCategory, Category $childCategory)
126 $bottomChildCategory = [];
127 while ($movedCategory->getName() != $childCategory->getName()) {
128 $bottomChildCategory[] = $movedCategory->getData();
129 $movedCategory = $movedCategory->getDataFieldConfig(
'parent_id')[
'source']->getParentCategory();
131 $bottomChildCategory[] = $movedCategory->getData();
134 for (
$i = count($bottomChildCategory) - 1;
$i >= 0;
$i--) {
135 unset($bottomChildCategory[
$i][
'parent_id']);
139 [
'data' => $bottomChildCategory[
$i]]
__inject(CatalogCategoryIndex $catalogCategoryIndex, CatalogCategoryEdit $catalogCategoryEdit, FixtureFactory $fixtureFactory)
test(Category $childCategory, Category $parentCategory, $moveLevel=null)
getMovedCategoryTree(Category $movedCategory, Category $parentCategory, Category $childCategory)