Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AssertAddressDeletedFrontend.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Customer\Test\Page\CustomerAccountIndex;
10 use Magento\Customer\Test\Page\CustomerAddressEdit;
11 use Magento\Mtf\Constraint\AbstractConstraint;
13 use Magento\Customer\Test\Fixture\Address;
14 
18 class AssertAddressDeletedFrontend extends AbstractConstraint
19 {
29  public function processAssert(
30  CustomerAccountIndex $customerAccountIndex,
31  CustomerAddressEdit $customerAddressEdit,
32  Customer $customer,
33  Address $addressToDelete
34  ) {
35  $this->objectManager->create(
36  \Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep::class,
37  ['customer' => $customer]
38  )->run();
39 
40  $customerAccountIndex->getAccountMenuBlock()->openMenuItem('Address Book');
41  $addressRenderer = $this->objectManager->create(
42  \Magento\Customer\Test\Block\Address\Renderer::class,
43  ['address' => $addressToDelete, 'type' => 'html']
44  );
45  $deletedAddress = $addressRenderer->render();
46 
47  $isAddressDeleted = false;
48  if ($customerAddressEdit->getEditForm()->isVisible()
49  || ($customerAccountIndex->getAdditionalAddressBlock()->getBlockText() !== null
50  && $deletedAddress != $customerAccountIndex->getAdditionalAddressBlock()->getBlockText())
51  || ($customerAccountIndex->getDefaultAddressBlock()->getBlockText() !== null
52  && $deletedAddress != $customerAccountIndex->getAdditionalAddressBlock()->getBlockText())
53  ) {
54  $isAddressDeleted = true;
55  }
56 
57  \PHPUnit\Framework\Assert::assertTrue(
58  $isAddressDeleted,
59  'Customer address was not deleted.'
60  );
61  }
62 
68  public function toString()
69  {
70  return 'Deleted address is absent in Frontend.';
71  }
72 }
$customer
Definition: customers.php:11
processAssert(CustomerAccountIndex $customerAccountIndex, CustomerAddressEdit $customerAddressEdit, Customer $customer, Address $addressToDelete)