Skip to content

Commit e8161ad

Browse files
committed
MAGETWO-60246: [Backport] - [Github]Magento 2.1.1 Problem with change currency #6746 - for 2.1.x
1 parent 36fc9a7 commit e8161ad

File tree

2 files changed

+26
-27
lines changed

2 files changed

+26
-27
lines changed

app/code/Magento/CatalogSearch/Model/Layer/Filter/Price.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,7 @@ public function getCurrencyRate()
156156
{
157157
$rate = $this->_getData('currency_rate');
158158
if ($rate === null) {
159-
$rate = $this->_storeManager->getStore($this->getStoreId())
160-
->getCurrentCurrencyRate();
159+
$rate = $this->_storeManager->getStore()->getCurrentCurrencyRate();
161160
}
162161
if (!$rate) {
163162
$rate = 1;

app/code/Magento/CatalogSearch/Test/Unit/Model/Layer/Filter/PriceTest.php

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,13 @@
1111

1212
/**
1313
* Test for \Magento\CatalogSearch\Model\Layer\Filter\Price
14-
* @SuppressWarnings(PHPMD.UnusedPrivateField)
1514
*/
1615
class PriceTest extends \PHPUnit_Framework_TestCase
1716
{
18-
private $itemDataBuilder;
19-
2017
/**
21-
* @var \Magento\Catalog\Model\Price|MockObject
18+
* @var \Magento\Catalog\Model\Layer\Filter\Item\DataBuilder|MockObject
2219
*/
23-
private $price;
20+
private $itemDataBuilder;
2421

2522
/**
2623
* @var \Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection|MockObject
@@ -48,69 +45,60 @@ class PriceTest extends \PHPUnit_Framework_TestCase
4845
/** @var \Magento\Catalog\Model\Layer\Filter\ItemFactory|MockObject */
4946
private $filterItemFactory;
5047

48+
/**
49+
* @var \Magento\Store\Api\Data\StoreInterface|MockObject
50+
*/
51+
private $storeMock;
52+
5153
/** @var \Magento\Catalog\Model\Layer\State|MockObject */
5254
private $state;
5355

5456
protected function setUp()
5557
{
5658
$this->request = $this->getMockBuilder('\Magento\Framework\App\RequestInterface')
57-
->disableOriginalConstructor()
58-
->setMethods(['getParam'])
5959
->getMockForAbstractClass();
6060

6161
$dataProviderFactory = $this->getMockBuilder('\Magento\Catalog\Model\Layer\Filter\DataProvider\PriceFactory')
6262
->disableOriginalConstructor()
6363
->setMethods(['create'])
6464
->getMock();
65-
6665
$this->dataProvider = $this->getMockBuilder('\Magento\Catalog\Model\Layer\Filter\DataProvider\Price')
6766
->disableOriginalConstructor()
6867
->setMethods(['setPriceId', 'getPrice'])
6968
->getMock();
70-
7169
$dataProviderFactory->expects($this->once())
7270
->method('create')
7371
->will($this->returnValue($this->dataProvider));
7472

7573
$this->layer = $this->getMockBuilder('\Magento\Catalog\Model\Layer')
7674
->disableOriginalConstructor()
77-
->setMethods(['getState', 'getProductCollection'])
7875
->getMock();
7976

8077
$this->state = $this->getMockBuilder('\Magento\Catalog\Model\Layer\State')
8178
->disableOriginalConstructor()
82-
->setMethods(['addFilter'])
8379
->getMock();
8480
$this->layer->expects($this->any())
8581
->method('getState')
8682
->will($this->returnValue($this->state));
8783

88-
$this->fulltextCollection = $this->fulltextCollection = $this->getMockBuilder(
84+
$this->fulltextCollection = $this->getMockBuilder(
8985
'\Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection'
90-
)
91-
->disableOriginalConstructor()
92-
->setMethods(['addFieldToFilter', 'getFacetedData'])
86+
)->disableOriginalConstructor()
9387
->getMock();
94-
9588
$this->layer->expects($this->any())
9689
->method('getProductCollection')
9790
->will($this->returnValue($this->fulltextCollection));
9891

9992
$this->itemDataBuilder = $this->getMockBuilder('\Magento\Catalog\Model\Layer\Filter\Item\DataBuilder')
10093
->disableOriginalConstructor()
101-
->setMethods(['addItemData', 'build'])
10294
->getMock();
10395

104-
$this->filterItemFactory = $this->getMockBuilder(
105-
'\Magento\Catalog\Model\Layer\Filter\ItemFactory'
106-
)
96+
$this->filterItemFactory = $this->getMockBuilder('\Magento\Catalog\Model\Layer\Filter\ItemFactory')
10797
->disableOriginalConstructor()
10898
->setMethods(['create'])
10999
->getMock();
110100

111-
$filterItem = $this->getMockBuilder(
112-
'\Magento\Catalog\Model\Layer\Filter\Item'
113-
)
101+
$filterItem = $this->getMockBuilder('\Magento\Catalog\Model\Layer\Filter\Item')
114102
->disableOriginalConstructor()
115103
->setMethods(['setFilter', 'setLabel', 'setValue', 'setCount'])
116104
->getMock();
@@ -123,12 +111,20 @@ protected function setUp()
123111

124112
$escaper = $this->getMockBuilder('\Magento\Framework\Escaper')
125113
->disableOriginalConstructor()
126-
->setMethods(['escapeHtml'])
127114
->getMock();
128115
$escaper->expects($this->any())
129116
->method('escapeHtml')
130117
->will($this->returnArgument(0));
131118

119+
$this->storeMock = $this->getMockBuilder(\Magento\Store\Api\Data\StoreInterface::class)
120+
->setMethods(['getCurrentCurrencyRate'])
121+
->getMockForAbstractClass();
122+
$storeManagerMock = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class)
123+
->getMockForAbstractClass();
124+
$storeManagerMock->expects($this->any())
125+
->method('getStore')
126+
->willReturn($this->storeMock);
127+
132128
$this->attribute = $this->getMockBuilder('\Magento\Eav\Model\Entity\Attribute')
133129
->disableOriginalConstructor()
134130
->setMethods(['getAttributeCode', 'getFrontend', 'getIsFilterable'])
@@ -142,14 +138,14 @@ protected function setUp()
142138
'itemDataBuilder' => $this->itemDataBuilder,
143139
'filterItemFactory' => $this->filterItemFactory,
144140
'escaper' => $escaper,
141+
'storeManager' => $storeManagerMock,
145142
]
146143
);
147144
}
148145

149146
/**
150147
* @param $requestValue
151148
* @param $idValue
152-
* @param $isIdUsed
153149
* @dataProvider applyWithEmptyRequestDataProvider
154150
*/
155151
public function testApplyWithEmptyRequest($requestValue, $idValue)
@@ -224,6 +220,10 @@ function ($field) use ($requestVar, $priceId) {
224220
->with('price')
225221
->will($this->returnSelf());
226222

223+
$this->storeMock->expects($this->atLeastOnce())
224+
->method('getCurrentCurrencyRate')
225+
->willReturn(1);
226+
227227
$this->target->apply($this->request);
228228
}
229229

0 commit comments

Comments
 (0)