Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AssertProductCompareSuccessAddMessage.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Catalog\Test\Page\Product\CatalogProductView;
10 use Magento\Mtf\Constraint\AbstractConstraint;
11 use Magento\Mtf\Fixture\FixtureInterface;
12 
16 class AssertProductCompareSuccessAddMessage extends AbstractConstraint
17 {
18  /* tags */
19  const SEVERITY = 'high';
20  /* end tags */
21 
22  const SUCCESS_MESSAGE = 'You added product %s to the comparison list.';
23 
31  public function processAssert(CatalogProductView $catalogProductView, FixtureInterface $product)
32  {
33  $successMessage = sprintf(self::SUCCESS_MESSAGE, $product->getName());
34  $actualMessage = $catalogProductView->getMessagesBlock()->getSuccessMessage();
35  \PHPUnit\Framework\Assert::assertEquals(
36  $successMessage,
37  $actualMessage,
38  'Wrong success message is displayed.'
39  . "\nExpected: " . $successMessage
40  . "\nActual: " . $actualMessage
41  );
42  }
43 
49  public function toString()
50  {
51  return 'Product has been added compare products list.';
52  }
53 }
processAssert(CatalogProductView $catalogProductView, FixtureInterface $product)