Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AssertProductAttributeIsComparable.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Catalog\Test\Fixture\CatalogProductAttribute;
10 use Magento\Catalog\Test\Page\Product\CatalogProductCompare;
11 use Magento\Catalog\Test\Page\Product\CatalogProductView;
12 use Magento\Mtf\Client\BrowserInterface;
13 use Magento\Mtf\Constraint\AbstractConstraint;
14 use Magento\Mtf\Fixture\InjectableFixture;
15 
19 class AssertProductAttributeIsComparable extends AbstractConstraint
20 {
30  public function processAssert(
31  InjectableFixture $product,
32  CatalogProductAttribute $attribute,
33  BrowserInterface $browser,
34  CatalogProductView $catalogProductView,
35  CatalogProductCompare $catalogProductCompare
36  ) {
37  $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
38  $catalogProductView->getViewBlock()->clickAddToCompare();
39  $catalogProductCompare->open();
40  $label = $attribute->hasData('manage_frontend_label')
41  ? $attribute->getManageFrontendLabel()
42  : $attribute->getFrontendLabel();
43 
44  \PHPUnit\Framework\Assert::assertTrue(
45  in_array($label, $catalogProductCompare->getCompareProductsBlock()->getComparableAttributes()),
46  'Attribute is absent on product compare page.'
47  );
48  }
49 
55  public function toString()
56  {
57  return 'Attribute is present on product compare page.';
58  }
59 }
processAssert(InjectableFixture $product, CatalogProductAttribute $attribute, BrowserInterface $browser, CatalogProductView $catalogProductView, CatalogProductCompare $catalogProductCompare)
$label
Definition: details.phtml:21