Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CacheInvalidationTest.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Mtf\TestCase\Injectable;
12 use Magento\Mtf\Client\BrowserInterface;
13 use Magento\Mtf\Fixture\FixtureFactory;
14 use Magento\Catalog\Test\Page\Adminhtml\CatalogProductEdit;
15 
29 class CacheInvalidationTest extends Injectable
30 {
31  /* tags */
32  const MVP = 'no';
33  /* end tags */
34 
40  private $browser;
41 
47  private $fixtureFactory;
48 
54  private $editProductPage;
55 
64  public function __inject(
65  BrowserInterface $browser,
66  FixtureFactory $fixtureFactory,
67  CatalogProductEdit $editProductPage
68  ) {
69  $this->browser = $browser;
70  $this->fixtureFactory = $fixtureFactory;
71  $this->editProductPage = $editProductPage;
72  }
73 
81  public function test(
82  CatalogProductSimple $product,
83  Store $store
84  ) {
85  //Preconditions:
86  $product->persist();
87  $store->persist();
88 
89  //Steps
90  $category = $product->getDataFieldConfig('category_ids')['source']->getCategories()[0];
91  $storeGroup = $store->getDataFieldConfig('group_id')['source']->getStoreGroup();
92  $website = $storeGroup->getDataFieldConfig('website_id')['source']->getWebsite();
93  $url = $_ENV['app_frontend_url'] . 'websites/' . $website->getCode() . '/' . $category->getUrlKey() . '.html';
94  $this->browser->open($url);
95  $this->browser->open($url);
96 
97  $productFixture = $this->fixtureFactory->createByCode(
98  'catalogProductSimple',
99  ['data' => ['website_ids' => [['store' => $store]]]]
100  );
101  $this->editProductPage->open(['id' => $product->getId()]);
102  $this->editProductPage->getProductForm()->fill($productFixture);
103  $this->editProductPage->getFormPageActions()->save();
104 
105  return [
106  'category' => $category,
107  ];
108  }
109 }
test(CatalogProductSimple $product, Store $store)
__inject(BrowserInterface $browser, FixtureFactory $fixtureFactory, CatalogProductEdit $editProductPage)