Skip to content

Commit 9a8b565

Browse files
committed
MAGETWO-70052: Fix not detecting current store using store code in url #9429O
- Unit test updated
1 parent c0fc522 commit 9a8b565

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

app/code/Magento/Checkout/Block/Checkout/DirectoryDataProcessor.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
namespace Magento\Checkout\Block\Checkout;
77

88
use Magento\Directory\Helper\Data as DirectoryHelper;
9-
use Magento\Store\Api\StoreResolverInterface;
109
use Magento\Store\Model\StoreManagerInterface;
10+
use Magento\Framework\App\ObjectManager;
1111

1212
/**
1313
* Directory data processor.
@@ -50,21 +50,21 @@ class DirectoryDataProcessor implements \Magento\Checkout\Block\Checkout\LayoutP
5050
/**
5151
* @param \Magento\Directory\Model\ResourceModel\Country\CollectionFactory $countryCollection
5252
* @param \Magento\Directory\Model\ResourceModel\Region\CollectionFactory $regionCollection
53-
* @param StoreResolverInterface $storeResolver
53+
* @param @deprecated $storeResolver
5454
* @param DirectoryHelper $directoryHelper
5555
* @param StoreManagerInterface $storeManager
5656
*/
5757
public function __construct(
5858
\Magento\Directory\Model\ResourceModel\Country\CollectionFactory $countryCollection,
5959
\Magento\Directory\Model\ResourceModel\Region\CollectionFactory $regionCollection,
60-
StoreResolverInterface $storeResolver,
60+
$storeResolver,
6161
DirectoryHelper $directoryHelper,
6262
StoreManagerInterface $storeManager = null
6363
) {
6464
$this->countryCollectionFactory = $countryCollection;
6565
$this->regionCollectionFactory = $regionCollection;
6666
$this->directoryHelper = $directoryHelper;
67-
$this->storeManager = $storeManager ?: \Magento\Framework\App\ObjectManager::getInstance()->get(StoreManagerInterface::class);
67+
$this->storeManager = $storeManager ?: ObjectManager::getInstance()->get(StoreManagerInterface::class);
6868
}
6969

7070
/**

app/code/Magento/Checkout/Test/Unit/Block/Checkout/DirectoryDataProcessorTest.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class DirectoryDataProcessorTest extends \PHPUnit_Framework_TestCase
4545
/**
4646
* @var \PHPUnit_Framework_MockObject_MockObject
4747
*/
48-
protected $directoryDataHelperMock;
48+
private $directoryDataHelperMock;
4949

5050
protected function setUp()
5151
{
@@ -80,9 +80,9 @@ protected function setUp()
8080
$this->storeResolverMock = $this->getMock(
8181
\Magento\Store\Api\StoreResolverInterface::class
8282
);
83-
$this->storeManagerMock = $this->getMock(
84-
\Magento\Store\Model\StoreManagerInterface::class
85-
);
83+
$this->storeManagerMock = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class)
84+
->disableOriginalConstructor()
85+
->getMock();
8686
$this->directoryDataHelperMock = $this->getMock(
8787
\Magento\Directory\Helper\Data::class,
8888
[],
@@ -107,6 +107,12 @@ public function testProcess()
107107
'region_id' => [],
108108
];
109109

110+
$storeMock = $this->getMockBuilder(\Magento\Store\Api\Data\StoreInterface::class)
111+
->disableOriginalConstructor()
112+
->getMock();
113+
$storeMock->expects($this->atLeastOnce())->method('getId')->willReturn(42);
114+
$this->storeManagerMock->expects($this->atLeastOnce())->method('getStore')->willReturn($storeMock);
115+
110116
$this->countryCollectionFactoryMock->expects($this->once())
111117
->method('create')
112118
->willReturn($this->countryCollectionMock);

0 commit comments

Comments
 (0)