Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
EditShippingAddressStep.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Checkout\Test\Page\CheckoutOnepage;
10 use Magento\Customer\Test\Fixture\Address;
11 use Magento\Mtf\ObjectManager;
12 use Magento\Mtf\TestStep\TestStepInterface;
13 
17 class EditShippingAddressStep implements TestStepInterface
18 {
24  protected $objectManager;
25 
31  private $checkoutOnepage;
32 
38  private $address;
39 
45  private $editAddress;
46 
52  private $save;
53 
62  public function __construct(
63  ObjectManager $objectManager,
64  CheckoutOnepage $checkoutOnepage,
65  Address $editShippingAddress = null,
67  $editSave = true
68  ) {
69  $this->objectManager = $objectManager;
70  $this->checkoutOnepage = $checkoutOnepage;
71  $this->editAddress = $editShippingAddress;
72  $this->address = $shippingAddress;
73  $this->save = $editSave;
74  }
75 
81  public function run()
82  {
83  $address = $this->objectManager->create(
84  \Magento\Customer\Test\Block\Address\Renderer::class,
85  ['address' => $this->address, 'type' => 'html_without_company']
86  )->render();
87 
88  $shippingBlock = $this->checkoutOnepage->getShippingBlock();
89  $shippingBlock->editAddress($address);
90  if ($this->editAddress) {
91  $shippingBlock->getAddressModalBlock()->fill($this->editAddress);
92  }
93  if ($this->save) {
94  $shippingBlock->getAddressModalBlock()->save();
95  } else {
96  $shippingBlock->getAddressModalBlock()->cancel();
97  }
98 
99  return ['shippingAddress' => $this->address];
100  }
101 }
$shippingAddress
Definition: order.php:40
__construct(ObjectManager $objectManager, CheckoutOnepage $checkoutOnepage, Address $editShippingAddress=null, Address $shippingAddress=null, $editSave=true)