Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CategoryUrlRewriteTest.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Catalog\Test\Page\Adminhtml\CatalogCategoryIndex;
10 use Magento\Catalog\Test\Page\Adminhtml\CatalogCategoryEdit;
12 use Magento\Mtf\TestCase\Injectable;
14 
35 class CategoryUrlRewriteTest extends Injectable
36 {
42  private $catalogCategoryIndex;
43 
49  private $catalogCategoryEdit;
50 
58  public function __inject(
59  CatalogCategoryIndex $catalogCategoryIndex,
60  CatalogCategoryEdit $catalogCategoryEdit
61  ) {
62  $this->catalogCategoryIndex = $catalogCategoryIndex;
63  $this->catalogCategoryEdit = $catalogCategoryEdit;
64  }
65 
75  public function test(Store $storeView, Category $childCategory, Category $parentCategory, Category $categoryUpdates)
76  {
77  // Preconditions:
78  $storeView->persist();
79  $parentCategory->persist();
80  $childCategory->persist();
81 
82  // Steps:
83  $this->catalogCategoryIndex->open();
84  $this->catalogCategoryIndex->getTreeCategories()->selectCategory($childCategory);
85  $this->catalogCategoryEdit->getFormPageActions()->selectStoreView($storeView->getName());
86  $this->catalogCategoryEdit->getEditForm()->fill($categoryUpdates);
87  $this->catalogCategoryEdit->getFormPageActions()->save();
88  $this->catalogCategoryIndex->getTreeCategories()->assignCategory(
89  $parentCategory->getName(),
90  $childCategory->getName()
91  );
92  if ($this->catalogCategoryEdit->getModalBlock()->isVisible()) {
93  $this->catalogCategoryEdit->getModalBlock()->acceptWarning();
94  }
95 
96  return [
97  'storeView' => $storeView,
98  'childCategory' => $childCategory,
99  'parentCategory' => $parentCategory
100  ];
101  }
102 }
__inject(CatalogCategoryIndex $catalogCategoryIndex, CatalogCategoryEdit $catalogCategoryEdit)
test(Store $storeView, Category $childCategory, Category $parentCategory, Category $categoryUpdates)