Skip to content

Commit 5475184

Browse files
author
Marcel Moldovan
committed
♻️ Add store resolver back to constructor parameters for back-compatibility
1 parent 0fcb792 commit 5475184

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

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

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

88
use Magento\Directory\Helper\Data as DirectoryHelper;
9+
use Magento\Store\Api\StoreResolverInterface;
910
use Magento\Store\Model\StoreManagerInterface;
1011

1112
/**
@@ -49,19 +50,21 @@ class DirectoryDataProcessor implements \Magento\Checkout\Block\Checkout\LayoutP
4950
/**
5051
* @param \Magento\Directory\Model\ResourceModel\Country\CollectionFactory $countryCollection
5152
* @param \Magento\Directory\Model\ResourceModel\Region\CollectionFactory $regionCollection
52-
* @param StoreManagerInterface $storeManager
53+
* @param StoreResolverInterface $storeResolver
5354
* @param DirectoryHelper $directoryHelper
55+
* @param StoreManagerInterface $storeManager
5456
*/
5557
public function __construct(
5658
\Magento\Directory\Model\ResourceModel\Country\CollectionFactory $countryCollection,
5759
\Magento\Directory\Model\ResourceModel\Region\CollectionFactory $regionCollection,
58-
StoreManagerInterface $storeManager,
59-
DirectoryHelper $directoryHelper
60+
StoreResolverInterface $storeResolver,
61+
DirectoryHelper $directoryHelper,
62+
StoreManagerInterface $storeManager = null
6063
) {
6164
$this->countryCollectionFactory = $countryCollection;
6265
$this->regionCollectionFactory = $regionCollection;
63-
$this->storeManager = $storeManager;
6466
$this->directoryHelper = $directoryHelper;
67+
$this->storeManager = $storeManager ?: \Magento\Framework\App\ObjectManager::getInstance()->get(StoreManagerInterface::class);
6568
}
6669

6770
/**

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ class DirectoryDataProcessorTest extends \PHPUnit_Framework_TestCase
3232
*/
3333
protected $regionCollectionMock;
3434

35+
/**
36+
* @var \PHPUnit_Framework_MockObject_MockObject
37+
*/
38+
protected $storeResolverMock;
39+
3540
/**
3641
* @var \PHPUnit_Framework_MockObject_MockObject
3742
*/
@@ -72,6 +77,9 @@ protected function setUp()
7277
'',
7378
false
7479
);
80+
$this->storeResolverMock = $this->getMock(
81+
\Magento\Store\Api\StoreResolverInterface::class
82+
);
7583
$this->storeManagerMock = $this->getMock(
7684
\Magento\Store\Model\StoreManagerInterface::class
7785
);
@@ -86,8 +94,9 @@ protected function setUp()
8694
$this->model = new \Magento\Checkout\Block\Checkout\DirectoryDataProcessor(
8795
$this->countryCollectionFactoryMock,
8896
$this->regionCollectionFactoryMock,
89-
$this->storeManagerMock,
90-
$this->directoryDataHelperMock
97+
$this->storeResolverMock,
98+
$this->directoryDataHelperMock,
99+
$this->storeManagerMock
91100
);
92101
}
93102

0 commit comments

Comments
 (0)