Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CacheStatusOnScheduledIndexingTest.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Mtf\TestCase\Injectable;
10 use Magento\Indexer\Test\Page\Adminhtml\IndexManagement;
11 use Magento\Catalog\Test\Page\Adminhtml\CatalogCategoryEdit;
13 use Magento\Mtf\Client\BrowserInterface;
15 use Magento\Mtf\Fixture\FixtureFactory;
16 
27 class CacheStatusOnScheduledIndexingTest extends Injectable
28 {
29  /* tags */
30  const MVP = 'no';
31  /* end tags */
32 
38  private $indexManagement;
39 
45  private $categoryEdit;
46 
52  private $browser;
53 
59  private $fixtureFactory;
60 
66  private $cache;
67 
78  public function __inject(
79  IndexManagement $indexManagement,
80  CatalogCategoryEdit $categoryEdit,
81  BrowserInterface $browser,
82  FixtureFactory $fixtureFactory,
83  Cache $cache
84  ) {
85  $this->indexManagement = $indexManagement;
86  $this->categoryEdit = $categoryEdit;
87  $this->browser = $browser;
88  $this->fixtureFactory = $fixtureFactory;
89  $this->cache = $cache;
90  }
91 
99  public function test(Category $initialCategory, Category $category)
100  {
101  $this->indexManagement->open();
102  $this->indexManagement->getMainBlock()->massaction([], 'Update by Schedule', false, 'Select All');
103  $initialCategory->persist();
104  $this->cache->flush();
105 
106  $this->browser->open($_ENV['app_frontend_url'] . $initialCategory->getUrlKey() . '.html');
107  $this->categoryEdit->open(['id' => $initialCategory->getId()]);
108  $this->categoryEdit->getEditForm()->fill($category);
109  $this->categoryEdit->getFormPageActions()->save();
110 
111  $products = $category->getDataFieldConfig('category_products')['source']->getProducts();
112  return [
113  'category' => $this->fixtureFactory->createByCode(
114  'category',
115  [
116  'data' => array_merge(
117  $initialCategory->getData(),
118  $category->getData(),
119  ['category_products' => ['products' => $products]]
120  )
121  ]
122  ),
123  ];
124  }
125 
131  public function tearDown()
132  {
133  $this->indexManagement->open();
134  $this->indexManagement->getMainBlock()->massaction([], 'Update on Save', false, 'Select All');
135  }
136 }
__inject(IndexManagement $indexManagement, CatalogCategoryEdit $categoryEdit, BrowserInterface $browser, FixtureFactory $fixtureFactory, Cache $cache)