Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AssertSwatchesAreVisibleOnCategoryPage.php
Go to the documentation of this file.
1 <?php
7 
8 use Magento\Catalog\Test\Page\Category\CatalogCategoryView;
9 use Magento\Cms\Test\Page\CmsIndex;
10 use Magento\Mtf\Constraint\AbstractConstraint;
11 use Magento\Mtf\Fixture\FixtureInterface;
12 
16 class AssertSwatchesAreVisibleOnCategoryPage extends AbstractConstraint
17 {
24  public function processAssert(
25  CatalogCategoryView $catalogCategoryView,
26  CmsIndex $cmsIndex,
27  FixtureInterface $product
28  ) {
29  $this->openCategoryPage($cmsIndex, $product);
30 
31  $isSwatchesBlockVisible = $catalogCategoryView->getListSwatchesProductBlock()
32  ->getProductItem($product)->isSwatchesBlockVisible();
33 
34  \PHPUnit\Framework\Assert::assertTrue(
35  $isSwatchesBlockVisible,
36  'Swatches are absent on category page.'
37  );
38  }
39 
47  private function openCategoryPage(
48  CmsIndex $cmsIndex,
49  FixtureInterface $product
50  ) {
51  $categoryIds = $product->getCategoryIds();
52  $categoryName = reset($categoryIds);
53  $cmsIndex->open();
54  $cmsIndex->getTopmenu()->selectCategoryByName($categoryName);
55  }
56 
62  public function toString()
63  {
64  return 'Swatches visibility is correct.';
65  }
66 }
processAssert(CatalogCategoryView $catalogCategoryView, CmsIndex $cmsIndex, FixtureInterface $product)