From 1717df443c0a679ca88db0ac2d1b8d0e9e7b878b Mon Sep 17 00:00:00 2001 From: RomanKis Date: Thu, 2 Nov 2017 15:31:19 +0200 Subject: [PATCH 1/2] 11793: Magento2.1.5 admin shipping report shows wrong currency code --- .../Block/Adminhtml/Grid/AbstractGrid.php | 9 +- .../Block/Adminhtml/Grid/AbstractGridTest.php | 92 +++++++++++++++++++ 2 files changed, 96 insertions(+), 5 deletions(-) create mode 100644 app/code/Magento/Reports/Test/Unit/Block/Adminhtml/Grid/AbstractGridTest.php diff --git a/app/code/Magento/Reports/Block/Adminhtml/Grid/AbstractGrid.php b/app/code/Magento/Reports/Block/Adminhtml/Grid/AbstractGrid.php index 48a87bf77cf94..158455db26455 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Grid/AbstractGrid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Grid/AbstractGrid.php @@ -363,12 +363,11 @@ public function setStoreIds($storeIds) public function getCurrentCurrencyCode() { if ($this->_currentCurrencyCode === null) { - $this->_currentCurrencyCode = count( - $this->_storeIds - ) > 0 ? $this->_storeManager->getStore( - array_shift($this->_storeIds) - )->getBaseCurrencyCode() : $this->_storeManager->getStore()->getBaseCurrencyCode(); + $this->_currentCurrencyCode = count($this->_storeIds) > 0 + ? $this->_storeManager->getStore(array_shift($this->_storeIds))->getCurrentCurrencyCode() + : $this->_storeManager->getStore()->getBaseCurrencyCode(); } + return $this->_currentCurrencyCode; } diff --git a/app/code/Magento/Reports/Test/Unit/Block/Adminhtml/Grid/AbstractGridTest.php b/app/code/Magento/Reports/Test/Unit/Block/Adminhtml/Grid/AbstractGridTest.php new file mode 100644 index 0000000000000..841837745c039 --- /dev/null +++ b/app/code/Magento/Reports/Test/Unit/Block/Adminhtml/Grid/AbstractGridTest.php @@ -0,0 +1,92 @@ +storeManagerMock = $this->getMockForAbstractClass( + \Magento\Store\Model\StoreManagerInterface::class, + [], + '', + true, + true, + true, + ['getStore'] + ); + + $this->model = $objectManager->getObject( + \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid::class, + ['_storeManager' => $this->storeManagerMock] + ); + + } + + /** + * @param $storeIds + * + * @dataProvider getCurrentCurrencyCodeDataProvider + */ + public function testGetCurrentCurrencyCode($storeIds) + { + $storeMock = $this->getMockForAbstractClass( + \Magento\Store\Api\Data\StoreInterface::class, + [], + '', + true, + true, + true, + ['getBaseCurrencyCode', 'getCurrentCurrencyCode'] + ); + + $this->storeManagerMock->expects($this->once())->method('getStore')->willReturn($storeMock); + + $this->model->setStoreIds($storeIds); + + if ($storeIds) { + $storeMock->expects($this->once())->method('getCurrentCurrencyCode')->willReturn('EUR'); + $expectedCurrencyCode = 'EUR'; + } else { + $storeMock->expects($this->once())->method('getBaseCurrencyCode')->willReturn('USD'); + $expectedCurrencyCode = 'USD'; + } + + $currencyCode = $this->model->getCurrentCurrencyCode(); + $this->assertEquals($expectedCurrencyCode, $currencyCode); + } + + /** + * DataProvider for testGetCurrentCurrencyCode. + * + * @return array + */ + public function getCurrentCurrencyCodeDataProvider() + { + return [ + [[]], + [[2]], + ]; + } +} From c438c171ce51c4893e706f6af02eb7cf3e80eec7 Mon Sep 17 00:00:00 2001 From: RomanKis Date: Thu, 2 Nov 2017 18:33:39 +0200 Subject: [PATCH 2/2] 11793: Magento2.1.5 admin shipping report shows wrong currency code --- .../Reports/Test/Unit/Block/Adminhtml/Grid/AbstractGridTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/code/Magento/Reports/Test/Unit/Block/Adminhtml/Grid/AbstractGridTest.php b/app/code/Magento/Reports/Test/Unit/Block/Adminhtml/Grid/AbstractGridTest.php index 841837745c039..dc16928861b1c 100644 --- a/app/code/Magento/Reports/Test/Unit/Block/Adminhtml/Grid/AbstractGridTest.php +++ b/app/code/Magento/Reports/Test/Unit/Block/Adminhtml/Grid/AbstractGridTest.php @@ -41,7 +41,6 @@ protected function setUp() \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid::class, ['_storeManager' => $this->storeManagerMock] ); - } /**