Skip to content

Commit 953dc16

Browse files
author
Mastiuhin Olexandr
committed
Merge branch 'MAGETWO-94295' into 2.2-develop-pr4
2 parents e7a68d0 + 427ffed commit 953dc16

File tree

2 files changed

+30
-0
lines changed
  • app/code/Magento/Sales

2 files changed

+30
-0
lines changed

app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/Address.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,11 @@ public function getAddressCollectionJson()
217217
*/
218218
protected function _prepareForm()
219219
{
220+
$storeId = $this->getCreateOrderModel()
221+
->getSession()
222+
->getStoreId();
223+
$this->_storeManager->setCurrentStore($storeId);
224+
220225
$fieldset = $this->_form->addFieldset('main', ['no_container' => true]);
221226

222227
$addressForm = $this->_customerFormFactory->create('customer_address', 'adminhtml_customer_address');

app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Address/FormTest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
use Magento\Sales\Model\Order;
2121
use Magento\Sales\Model\Order\Address;
2222
use PHPUnit_Framework_MockObject_MockObject as MockObject;
23+
use Magento\Backend\Model\Session\Quote as QuoteSession;
24+
use Magento\Sales\Model\AdminOrder\Create;
2325

2426
/**
2527
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -51,6 +53,16 @@ class FormTest extends \PHPUnit\Framework\TestCase
5153
*/
5254
private $countriesCollection;
5355

56+
/**
57+
* @var Create|MockObject
58+
*/
59+
private $orderCreate;
60+
61+
/**
62+
* @var QuoteSession|MockObject
63+
*/
64+
private $sessionQuote;
65+
5466
protected function setUp()
5567
{
5668
$objectManager = new ObjectManager($this);
@@ -61,6 +73,15 @@ protected function setUp()
6173
$this->countriesCollection = $this->createMock(
6274
Collection::class
6375
);
76+
$this->sessionQuote = $this->getMockBuilder(QuoteSession::class)
77+
->disableOriginalConstructor()
78+
->setMethods(['getStoreId', 'getStore'])
79+
->getMock();
80+
$this->orderCreate = $this->getMockBuilder(Create::class)
81+
->disableOriginalConstructor()
82+
->getMock();
83+
$this->orderCreate->method('getSession')
84+
->willReturn($this->sessionQuote);
6485

6586
$this->addressBlock = $objectManager->getObject(
6687
Form::class,
@@ -69,6 +90,8 @@ protected function setUp()
6990
'_customerFormFactory' => $this->customerFormFactory,
7091
'_coreRegistry' => $this->coreRegistry,
7192
'countriesCollection' => $this->countriesCollection,
93+
'sessionQuote' => $this->sessionQuote,
94+
'_orderCreate' => $this->orderCreate
7295
]
7396
);
7497
}
@@ -108,6 +131,8 @@ public function testGetForm()
108131
->willReturn($order);
109132
$order->method('getStoreId')
110133
->willReturn($storeId);
134+
$this->sessionQuote->method('getStoreId')
135+
->willReturn($storeId);
111136
$this->countriesCollection->method('loadByStore')
112137
->with($storeId)
113138
->willReturn($this->countriesCollection);

0 commit comments

Comments
 (0)