10 use Magento\Catalog\Test\Page\Adminhtml\CatalogCategoryEdit;
11 use Magento\Catalog\Test\Page\Adminhtml\CatalogCategoryIndex;
12 use Magento\Mtf\TestCase\Injectable;
13 use Magento\Mtf\Fixture\FixtureFactory;
40 private $catalogCategoryIndex;
47 private $catalogCategoryEdit;
54 private $fixtureFactory;
65 CatalogCategoryIndex $catalogCategoryIndex,
66 CatalogCategoryEdit $catalogCategoryEdit,
67 FixtureFactory $fixtureFactory
69 $this->fixtureFactory = $fixtureFactory;
70 $this->catalogCategoryIndex = $catalogCategoryIndex;
71 $this->catalogCategoryEdit = $catalogCategoryEdit;
84 Category $initialCategory,
87 $initialCategory->persist();
88 $topCategory = $this->getParentCategoryByNestingLevel($initialCategory, $nestingLevel);
89 $this->catalogCategoryIndex->open();
90 $this->catalogCategoryIndex->getTreeCategories()->selectCategory($topCategory);
91 $this->catalogCategoryEdit->getEditForm()->fill(
$category);
92 $this->catalogCategoryEdit->getFormPageActions()->save();
111 private function getCategoryFixture(array &
$categories, Category $currentCategory, array
$data,
int $nestingLevel)
113 if (--$nestingLevel) {
114 $parentCategory = $this->getCategoryFixture(
116 $currentCategory->getDataFieldConfig(
'parent_id')[
'source']->getParentCategory(),
120 $category = $this->fixtureFactory->createByCode(
122 [
'data' => array_merge($currentCategory->getData(), [
'parent_id' => [
'source' => $parentCategory]])]
125 $category = $this->fixtureFactory->createByCode(
127 [
'data' => array_merge($currentCategory->getData(),
$data)]
141 private function getParentCategoryByNestingLevel(Category
$category, $nestingLevel)
143 for ($nestingIterator = 1; $nestingIterator < $nestingLevel; $nestingIterator++) {
144 $category =
$category->getDataFieldConfig(
'parent_id')[
'source']->getParentCategory();