Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AssertCartPerCustomer.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Mtf\Constraint\AbstractConstraint;
10 use Magento\Checkout\Test\Page\CheckoutCart;
11 use Magento\Cms\Test\Page\CmsIndex;
12 use Magento\Mtf\TestStep\TestStepFactory;
13 
17 class AssertCartPerCustomer extends AbstractConstraint
18 {
22  const WELCOME_MESSAGE = 'Welcome, %s!';
23 
38  public function processAssert(
39  CheckoutCart $checkoutCart,
40  CmsIndex $cmsIndex,
41  TestStepFactory $stepFactory,
42  array $customers,
43  array $cartFixtures,
44  AssertProductQtyInShoppingCart $assertProductQty,
45  AssertSubtotalInShoppingCart $assertSubtotal,
46  AssertGrandTotalInShoppingCart $assertGrandtotal,
48  ) {
49  foreach ($customers as $index => $customer) {
50  if (!empty($cartFixtures[$index])) {
51  $stepFactory->create(
52  \Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep::class,
53  ['customer' => $customer]
54  )->run();
55  \PHPUnit\Framework\Assert::assertEquals(
56  sprintf(
57  self::WELCOME_MESSAGE,
58  $customer->getFirstname() . ' ' . $customer->getLastname()
59  ),
60  $cmsIndex->getLinksBlock()->getWelcomeText(),
61  'Customer welcome message is wrong.'
62  );
63  $assertProductQty->processAssert($checkoutCart, $cartFixtures[$index]);
64  $assertSubtotal->processAssert($checkoutCart, $cartFixtures[$index]);
65  $assertGrandtotal->processAssert($checkoutCart, $cartFixtures[$index]);
66  $assertMinicart->processAssert($cmsIndex, $cartFixtures[$index]);
67  }
68  }
69  }
70 
76  public function toString()
77  {
78  return 'Shopping cart data is correct for each customer.';
79  }
80 }
$customer
Definition: customers.php:11
processAssert(CheckoutCart $checkoutCart, Cart $cart, $requireReload=true)
processAssert(CheckoutCart $checkoutCart, CmsIndex $cmsIndex, TestStepFactory $stepFactory, array $customers, array $cartFixtures, AssertProductQtyInShoppingCart $assertProductQty, AssertSubtotalInShoppingCart $assertSubtotal, AssertGrandTotalInShoppingCart $assertGrandtotal, AssertProductDataInMiniShoppingCart $assertMinicart)
$index
Definition: list.phtml:44