Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
FillCustomerAddressesStep.php
Go to the documentation of this file.
1 <?php
7 
9 use Magento\Mtf\ObjectManager;
10 use Magento\Multishipping\Test\Page\MultishippingCheckoutAddresses;
11 use Magento\Mtf\TestStep\TestStepInterface;
12 
16 class FillCustomerAddressesStep implements TestStepInterface
17 {
23  protected $addresses;
24 
30  protected $addressRender;
31 
37  protected $objectManager;
38 
44  protected $products;
45 
51  private $customer;
52 
59  public function __construct(
60  MultishippingCheckoutAddresses $addresses,
61  Customer $customer,
62  ObjectManager $objectManager,
63  $products
64  ) {
65  $this->addresses = $addresses;
66  $this->customer = $customer;
67  $this->products = $products;
68  $this->objectManager = $objectManager;
69  $this->objectManager->configure(
70  [\Magento\Customer\Test\Block\Address\Renderer::class => ['shared' => false]]
71  );
72  }
73 
79  public function run()
80  {
81  $addresses = $this->customer->getDataFieldConfig('address')['source']->getAddresses();
82  $bindings = [];
83 
84  foreach ($this->products as $key => $product) {
85  $productName = $product->getName();
86  $addressRender = $this->objectManager->create(
87  \Magento\Customer\Test\Block\Address\Renderer::class,
88  ['address' => $addresses[$key], 'type' => 'oneline']
89  );
90  $bindings[$productName] = $addressRender->render();
91  }
92  $this->addresses->getAddressesBlock()->selectAddresses($bindings);
93  }
94 }
$customer
Definition: customers.php:11
__construct(MultishippingCheckoutAddresses $addresses, Customer $customer, ObjectManager $objectManager, $products)