Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AssertConfigurableProductInCart.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Catalog\Test\Page\Product\CatalogProductView;
10 use Magento\Checkout\Test\Page\CheckoutCart;
12 use Magento\Mtf\Client\BrowserInterface;
13 use Magento\Mtf\Constraint\AbstractConstraint;
14 
19 class AssertConfigurableProductInCart extends AbstractConstraint
20 {
30  public function processAssert(
31  BrowserInterface $browser,
32  CatalogProductView $catalogProductView,
33  CheckoutCart $checkoutCart,
35  ) {
36  $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
37 
38  $catalogProductView->getViewBlock()->addToCart($product);
39  $catalogProductView->getMessagesBlock()->waitSuccessMessage();
40  $checkoutCart->open();
41 
42  $checkoutData = $product->getCheckoutData();
43  $price = $checkoutCart->getCartBlock()->getCartItem($product)->getPrice();
44  \PHPUnit\Framework\Assert::assertEquals(
45  $checkoutData['cartItem']['price'],
46  $price,
47  'Product price in shopping cart is not correct.'
48  );
49  }
50 
56  public function toString()
57  {
58  return 'Product price in shopping cart is correct.';
59  }
60 }
$price
processAssert(BrowserInterface $browser, CatalogProductView $catalogProductView, CheckoutCart $checkoutCart, ConfigurableProduct $product)