Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AddressesTest.php
Go to the documentation of this file.
1 <?php
7 
9 
13 class AddressesTest extends \PHPUnit\Framework\TestCase
14 {
16 
20  protected $_addresses;
21 
25  protected $_objectManager;
26 
27  protected function setUp()
28  {
29  $this->_objectManager = Bootstrap::getObjectManager();
32  \Magento\Customer\Api\CustomerRepositoryInterface::class
33  );
34  $customerData = $customerRepository->getById(self::FIXTURE_CUSTOMER_ID);
35 
37  $customerSession = $this->_objectManager->get(\Magento\Customer\Model\Session::class);
38  $customerSession->setCustomerData($customerData);
39 
41  $quoteCollection = $this->_objectManager->get(\Magento\Quote\Model\ResourceModel\Quote\Collection::class);
43  $quote = $quoteCollection->getLastItem();
44 
46  $checkoutSession = $this->_objectManager->get(\Magento\Checkout\Model\Session::class);
47  $checkoutSession->setQuoteId($quote->getId());
48  $checkoutSession->setLoadInactive(true);
49 
50  $this->_addresses = $this->_objectManager->create(
51  \Magento\Multishipping\Block\Checkout\Addresses::class
52  );
53  }
54 
60  public function testGetAddressOptions()
61  {
62  $expectedResult = [
63  [
64  'value' => '1',
65  'label' => 'John Smith, Green str, 67, CityM, Alabama 75477, United States',
66  ],
67  ];
68 
69  $addressAsHtml = $this->_addresses->getAddressOptions();
70  $this->assertEquals($expectedResult, $addressAsHtml);
71  }
72 }
$customerData
$quote
$customerRepository
$quoteCollection