-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge forwardport of #11962 to 2.3-develop branch
Applied pull request patch https://github.com/magento/magento2/pull/11962.patch (created by @RomaKis) based on commit(s): 1. 1717df4 2. c438c17 3. 42d9b52 Fixed GitHub Issues in 2.3-develop branch: - #11793: Magento2.1.5 admin shipping report shows wrong currency code (reported by @pushparaj100)
- Loading branch information
Showing
2 changed files
with
95 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
app/code/Magento/Reports/Test/Unit/Block/Adminhtml/Grid/AbstractGridTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Magento\Reports\Test\Unit\Block\Adminhtml\Grid; | ||
|
||
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; | ||
|
||
/** | ||
* Test for class \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid. | ||
*/ | ||
class AbstractGridTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
/** | ||
* @var \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
private $model; | ||
|
||
/** | ||
* @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
private $storeManagerMock; | ||
|
||
protected function setUp() | ||
{ | ||
$objectManager = new ObjectManager($this); | ||
|
||
$this->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]], | ||
]; | ||
} | ||
} |