Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AssertVisibleItemsQtyInCheckoutSummaryBlock.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Mtf\Constraint\AbstractConstraint;
11 use Magento\Checkout\Test\Page\CheckoutOnepage;
13 
14 class AssertVisibleItemsQtyInCheckoutSummaryBlock extends AbstractConstraint
15 {
24  public function processAssert(
25  CheckoutOnepage $checkoutPage,
26  Cart $cart,
27  $checkoutSummaryMaxVisibleCartItemsCount
28  ) {
29  $reviewBlock = $checkoutPage->getReviewBlock();
30  $reviewBlock->expandItemsBlock();
31 
32  $sourceProducts = $cart->getDataFieldConfig('items')['source'];
33  $products = $sourceProducts->getProducts();
34 
35  $presentItems = 0;
36  foreach (array_keys($cart->getItems()) as $key) {
38  $product = $products[$key];
39  if ($reviewBlock->getItemElement($product->getName())->isVisible()) {
40  $presentItems++;
41  }
42  }
43 
44  \PHPUnit\Framework\Assert::assertEquals(
45  $checkoutSummaryMaxVisibleCartItemsCount,
46  $presentItems,
47  'Wrong quantity of visible Cart items in checkout summary block.'
48  );
49  }
50 
56  public function toString()
57  {
58  return 'Quantity of visible Cart items the same as checkout configuration value.';
59  }
60 }