-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MAGETWO-85305: 12560: Back-End issue for multi-store website: when ed…
…iting Order shipping/billing address - allowed countries are selected from wrong Store View #982 - Merge Pull Request magento-engcom/magento2ce#982 from RomaKis/magento2:12560 - Merged commits: 1. 41db211
- Loading branch information
Showing
3 changed files
with
117 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Address/FormTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Magento\Sales\Test\Unit\Block\Adminhtml\Order\Address; | ||
|
||
/** | ||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects) | ||
*/ | ||
class FormTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
/** | ||
* @var \Magento\Sales\Block\Adminhtml\Order\Address\Form | ||
*/ | ||
private $addressBlock; | ||
|
||
/** | ||
* @var \PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
private $formFactoryMock; | ||
|
||
/** | ||
* @var \PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
private $customerFormFactoryMock; | ||
|
||
/** | ||
* @var \PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
private $coreRegistryMock; | ||
|
||
/** | ||
* @var \PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
private $countriesCollection; | ||
|
||
protected function setUp() | ||
{ | ||
$objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); | ||
|
||
$this->formFactoryMock = $this->createMock(\Magento\Framework\Data\FormFactory::class); | ||
$this->customerFormFactoryMock = $this->createMock(\Magento\Customer\Model\Metadata\FormFactory::class); | ||
$this->coreRegistryMock = $this->createMock(\Magento\Framework\Registry::class); | ||
$this->countriesCollection = $this->createMock( | ||
\Magento\Directory\Model\ResourceModel\Country\Collection::class | ||
); | ||
|
||
$this->addressBlock = $objectManager->getObject( | ||
\Magento\Sales\Block\Adminhtml\Order\Address\Form::class, | ||
[ | ||
'_formFactory' => $this->formFactoryMock, | ||
'_customerFormFactory' => $this->customerFormFactoryMock, | ||
'_coreRegistry' => $this->coreRegistryMock, | ||
'countriesCollection' => $this->countriesCollection, | ||
] | ||
); | ||
} | ||
|
||
public function testGetForm() | ||
{ | ||
$formMock = $this->createMock(\Magento\Framework\Data\Form::class); | ||
$fieldsetMock = $this->createMock(\Magento\Framework\Data\Form\Element\Fieldset::class); | ||
$addressFormMock = $this->createMock(\Magento\Customer\Model\Metadata\Form::class); | ||
$addressMock = $this->createMock(\Magento\Sales\Model\Order\Address::class); | ||
$selectMock = $this->createMock(\Magento\Framework\Data\Form\Element\Select::class); | ||
$orderMock = $this->createMock(\Magento\Sales\Model\Order::class); | ||
|
||
$this->formFactoryMock->expects($this->atLeastOnce())->method('create')->willReturn($formMock); | ||
$formMock->expects($this->atLeastOnce())->method('addFieldset')->willReturn($fieldsetMock); | ||
$this->customerFormFactoryMock->expects($this->atLeastOnce())->method('create')->willReturn($addressFormMock); | ||
$addressFormMock->expects($this->atLeastOnce())->method('getAttributes')->willReturn([]); | ||
$this->coreRegistryMock->expects($this->atLeastOnce())->method('registry')->willReturn($addressMock); | ||
$formMock->expects($this->atLeastOnce())->method('getElement')->willReturnOnConsecutiveCalls( | ||
$selectMock, | ||
$selectMock, | ||
$selectMock, | ||
$selectMock, | ||
$selectMock, | ||
$selectMock, | ||
$selectMock, | ||
null | ||
); | ||
$addressMock->expects($this->once())->method('getOrder')->willReturn($orderMock); | ||
$orderMock->expects($this->once())->method('getStoreId')->willReturn(5); | ||
$this->countriesCollection->expects($this->atLeastOnce())->method('loadByStore') | ||
->willReturn($this->countriesCollection); | ||
|
||
$this->addressBlock->getForm(); | ||
} | ||
} |