Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AssertProductInCustomStoreView.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Catalog\Test\Page\Product\CatalogProductView;
10 use Magento\Mtf\Client\BrowserInterface;
13 use Magento\Cms\Test\Page\CmsIndex;
14 use Magento\Mtf\Fixture\FixtureInterface;
15 
20 {
26  private $productViewPage;
27 
33  private $browser;
34 
40  private $cmsIndexPage;
41 
53  public function processAssert(
54  BrowserInterface $browser,
55  CatalogProductView $catalogProductView,
56  FixtureInterface $product,
57  FixtureInterface $initialProduct,
58  Store $store,
59  CmsIndex $cmsIndexPage
60  ) {
61  $this->browser = $browser;
62  $this->cmsIndexPage = $cmsIndexPage;
63  $this->productViewPage = $catalogProductView;
64 
65  $this->verifyProductOnMainStore($initialProduct);
66  $this->verifyProductOnCustomStore($product, $store);
67  }
68 
75  protected function verifyProductOnMainStore(FixtureInterface $initialProduct)
76  {
77  $this->browser->open($_ENV['app_frontend_url'] . $initialProduct->getUrlKey() . '.html');
78 
79  \PHPUnit\Framework\Assert::assertEquals(
80  $initialProduct->getName(),
81  $this->productViewPage->getViewBlock()->getProductName(),
82  'Product ' . $initialProduct->getName() . ' is incorrect.'
83  );
84  }
85 
93  protected function verifyProductOnCustomStore(FixtureInterface $updatedProduct, Store $store)
94  {
95  $this->cmsIndexPage->getStoreSwitcherBlock()->selectStoreView($store->getName());
96  $this->cmsIndexPage->getLinksBlock()->waitWelcomeMessage();
97 
98  $this->browser->open($_ENV['app_frontend_url'] . $updatedProduct->getUrlKey() . '.html');
99 
100  \PHPUnit\Framework\Assert::assertEquals(
101  $updatedProduct->getName(),
102  $this->productViewPage->getViewBlock()->getProductName(),
103  'Product ' . $updatedProduct->getName() . ' is not available on ' . $store->getName() . ' store.'
104  );
105  }
106 
112  public function toString()
113  {
114  return 'Product is displayed correctly in default and custom store views.';
115  }
116 }
processAssert(BrowserInterface $browser, CatalogProductView $catalogProductView, FixtureInterface $product, FixtureInterface $initialProduct, Store $store, CmsIndex $cmsIndexPage)
verifyProductOnCustomStore(FixtureInterface $updatedProduct, Store $store)