Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AssertCustomerDefaultAddressFrontendAddressBook.php
Go to the documentation of this file.
1 <?php
8 
10 use Magento\Customer\Test\Fixture\Address;
11 use Magento\Customer\Test\Page\CustomerAccountAddress;
12 use Magento\Customer\Test\Page\CustomerAccountIndex;
13 use Magento\Mtf\Constraint\AbstractConstraint;
14 
18 class AssertCustomerDefaultAddressFrontendAddressBook extends AbstractConstraint
19 {
29  public function processAssert(
30  CustomerAccountIndex $customerAccountIndex,
31  CustomerAccountAddress $customerAddress,
34  ) {
35  $customerAccountIndex->open();
36  $customerAccountIndex->getAccountMenuBlock()->openMenuItem('Address Book');
37 
38  $shippingAddressRendered = $this->createAddressRenderer($shippingAddress)->render();
39  $defaultShippingAddress = $customerAddress->getDefaultAddressBlock()->getDefaultShippingAddress();
40  $validated = strpos($defaultShippingAddress, trim($shippingAddressRendered)) !== false;
41  if (null !== $billingAddress) {
42  $billingAddressRendered = $customerAddress->getDefaultAddressBlock()->getDefaultBillingAddress();
43  $validated =
44  $validated && ($billingAddressRendered == $this->createAddressRenderer($billingAddress)->render());
45  }
46 
47  \PHPUnit\Framework\Assert::assertTrue(
48  $validated,
49  'Customer default address on address book tab is not matching the fixture.'
50  );
51  }
52 
58  public function toString()
59  {
60  return 'Default billing and shipping address form is correct.';
61  }
62 
69  private function createAddressRenderer(Address $address)
70  {
71  return $this->objectManager->create(
72  Renderer::class,
73  ['address' => $address, 'type' => 'html']
74  );
75  }
76 }
$billingAddress
Definition: order.php:25
$shippingAddress
Definition: order.php:40
$address
Definition: customer.php:38
processAssert(CustomerAccountIndex $customerAccountIndex, CustomerAccountAddress $customerAddress, Address $shippingAddress, Address $billingAddress=null)
$customerAddress