Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AssertProductIsNotVisibleInComparePage.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Catalog\Test\Page\Product\CatalogProductCompare;
10 use Magento\Mtf\Constraint\AbstractConstraint;
11 use Magento\Mtf\Fixture\FixtureInterface;
12 
17 class AssertProductIsNotVisibleInComparePage extends AbstractConstraint
18 {
19  /* tags */
20  const SEVERITY = 'low';
21  /* end tags */
22 
23  const SUCCESS_MESSAGE = 'You have no items to compare.';
24 
33  public function processAssert(CatalogProductCompare $comparePage, FixtureInterface $product, $countProducts = 0)
34  {
35  $comparePage->open();
36  $compareBlock = $comparePage->getCompareProductsBlock();
37 
38  if ($countProducts > 1) {
39  \PHPUnit\Framework\Assert::assertFalse(
40  $compareBlock->isProductVisibleInCompareBlock($product->getName()),
41  'The product displays on Compare Products page.'
42  );
43  } else {
44  \PHPUnit\Framework\Assert::assertEquals(
45  self::SUCCESS_MESSAGE,
46  $compareBlock->getEmptyMessage(),
47  'The product displays on Compare Products page.'
48  );
49  }
50  }
51 
57  public function toString()
58  {
59  return 'Products is not displayed on Compare Products page.';
60  }
61 }
processAssert(CatalogProductCompare $comparePage, FixtureInterface $product, $countProducts=0)