Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit f200382

Browse files
committed
MAGETWO-83197: 11793: Magento2.1.5 admin shipping report shows wrong currency code #11962
- Merge Pull Request magento/magento2#11962 from RomaKis/magento2:11793 - Merged commits: 1. 1717df4 2. c438c17 3. 42d9b52
2 parents dbcc3c4 + 42d9b52 commit f200382

File tree

2 files changed

+95
-5
lines changed

2 files changed

+95
-5
lines changed

app/code/Magento/Reports/Block/Adminhtml/Grid/AbstractGrid.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -363,12 +363,11 @@ public function setStoreIds($storeIds)
363363
public function getCurrentCurrencyCode()
364364
{
365365
if ($this->_currentCurrencyCode === null) {
366-
$this->_currentCurrencyCode = count(
367-
$this->_storeIds
368-
) > 0 ? $this->_storeManager->getStore(
369-
array_shift($this->_storeIds)
370-
)->getBaseCurrencyCode() : $this->_storeManager->getStore()->getBaseCurrencyCode();
366+
$this->_currentCurrencyCode = count($this->_storeIds) > 0
367+
? $this->_storeManager->getStore(array_shift($this->_storeIds))->getCurrentCurrencyCode()
368+
: $this->_storeManager->getStore()->getBaseCurrencyCode();
371369
}
370+
372371
return $this->_currentCurrencyCode;
373372
}
374373

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Reports\Test\Unit\Block\Adminhtml\Grid;
8+
9+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
10+
11+
/**
12+
* Test for class \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid.
13+
*/
14+
class AbstractGridTest extends \PHPUnit\Framework\TestCase
15+
{
16+
/**
17+
* @var \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid|\PHPUnit_Framework_MockObject_MockObject
18+
*/
19+
private $model;
20+
21+
/**
22+
* @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
23+
*/
24+
private $storeManagerMock;
25+
26+
protected function setUp()
27+
{
28+
$objectManager = new ObjectManager($this);
29+
30+
$this->storeManagerMock = $this->getMockForAbstractClass(
31+
\Magento\Store\Model\StoreManagerInterface::class,
32+
[],
33+
'',
34+
true,
35+
true,
36+
true,
37+
['getStore']
38+
);
39+
40+
$this->model = $objectManager->getObject(
41+
\Magento\Reports\Block\Adminhtml\Grid\AbstractGrid::class,
42+
['_storeManager' => $this->storeManagerMock]
43+
);
44+
}
45+
46+
/**
47+
* @param $storeIds
48+
*
49+
* @dataProvider getCurrentCurrencyCodeDataProvider
50+
*/
51+
public function testGetCurrentCurrencyCode($storeIds)
52+
{
53+
$storeMock = $this->getMockForAbstractClass(
54+
\Magento\Store\Api\Data\StoreInterface::class,
55+
[],
56+
'',
57+
true,
58+
true,
59+
true,
60+
['getBaseCurrencyCode', 'getCurrentCurrencyCode']
61+
);
62+
63+
$this->storeManagerMock->expects($this->once())->method('getStore')->willReturn($storeMock);
64+
65+
$this->model->setStoreIds($storeIds);
66+
67+
if ($storeIds) {
68+
$storeMock->expects($this->once())->method('getCurrentCurrencyCode')->willReturn('EUR');
69+
$expectedCurrencyCode = 'EUR';
70+
} else {
71+
$storeMock->expects($this->once())->method('getBaseCurrencyCode')->willReturn('USD');
72+
$expectedCurrencyCode = 'USD';
73+
}
74+
75+
$currencyCode = $this->model->getCurrentCurrencyCode();
76+
$this->assertEquals($expectedCurrencyCode, $currencyCode);
77+
}
78+
79+
/**
80+
* DataProvider for testGetCurrentCurrencyCode.
81+
*
82+
* @return array
83+
*/
84+
public function getCurrentCurrencyCodeDataProvider()
85+
{
86+
return [
87+
[[]],
88+
[[2]],
89+
];
90+
}
91+
}

0 commit comments

Comments
 (0)