Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AssertAddedProductToCartSuccessMessage.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Checkout\Test\Page\CheckoutCart;
10 use Magento\Mtf\Constraint\AbstractConstraint;
11 use Magento\Mtf\Fixture\FixtureInterface;
12 
17 class AssertAddedProductToCartSuccessMessage extends AbstractConstraint
18 {
22  const SUCCESS_MESSAGE = 'You added %s to your shopping cart.';
23 
31  public function processAssert(CheckoutCart $checkoutCart, FixtureInterface $product)
32  {
33  \PHPUnit\Framework\Assert::assertEquals(
34  sprintf(self::SUCCESS_MESSAGE, $product->getName()),
35  $checkoutCart->getMessagesBlock()->getSuccessMessage()
36  );
37  }
38 
44  public function toString()
45  {
46  return 'Add to cart success message is present on Shopping Cart page.';
47  }
48 }