|
1 | 1 | <?php
|
2 | 2 | /**
|
3 |
| - * Copyright © Magento, Inc. All rights reserved. |
4 |
| - * See COPYING.txt for license details. |
| 3 | + * Copyright 2014 Adobe |
| 4 | + * All Rights Reserved. |
5 | 5 | */
|
6 | 6 | declare(strict_types=1);
|
7 | 7 |
|
|
16 | 16 | use Magento\Framework\DataObject;
|
17 | 17 | use Magento\Framework\Locale\CurrencyInterface;
|
18 | 18 | use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
|
| 19 | +use Magento\Store\Model\Store; |
19 | 20 | use Magento\Store\Model\StoreManagerInterface;
|
| 21 | +use Magento\Store\Model\Website; |
20 | 22 | use PHPUnit\Framework\MockObject\MockObject;
|
21 | 23 | use PHPUnit\Framework\TestCase;
|
22 | 24 |
|
@@ -138,4 +140,42 @@ public function testRenderWithDefaultCurrency()
|
138 | 140 |
|
139 | 141 | $this->assertEquals('15USD', $this->_blockCurrency->render($this->_row));
|
140 | 142 | }
|
| 143 | + |
| 144 | + /** |
| 145 | + * @covers \Magento\Backend\Block\Widget\Grid\Column\Renderer\Currency::render |
| 146 | + */ |
| 147 | + public function testRenderWithNonDefaultCurrency() |
| 148 | + { |
| 149 | + $this->_currencyMock->expects($this->once()) |
| 150 | + ->method('getRate') |
| 151 | + ->with('nonDefaultCurrency') |
| 152 | + ->willReturn(2.0); |
| 153 | + $this->_curLocatorMock->expects($this->never()) |
| 154 | + ->method('getDefaultCurrency'); |
| 155 | + $currLocaleMock = $this->createMock(CurrencyData::class); |
| 156 | + $currLocaleMock->expects($this->once()) |
| 157 | + ->method('toCurrency') |
| 158 | + ->with(20.0000) |
| 159 | + ->willReturn('20EUR'); |
| 160 | + $this->_localeMock->expects($this->once()) |
| 161 | + ->method('getCurrency') |
| 162 | + ->with('nonDefaultCurrency') |
| 163 | + ->willReturn($currLocaleMock); |
| 164 | + $this->_columnMock->method('getCurrency')->willReturn('EUR'); |
| 165 | + $this->_columnMock->method('getRateField')->willReturn('test_rate_field'); |
| 166 | + $this->_row->setData('store_id', 1); |
| 167 | + $storeMock = $this->createMock(Store::class); |
| 168 | + $websiteMock = $this->createMock(Website::class); |
| 169 | + $websiteMock->expects($this->exactly(2)) |
| 170 | + ->method('getBaseCurrencyCode') |
| 171 | + ->willReturn('nonDefaultCurrency'); |
| 172 | + $storeMock->expects($this->exactly(2)) |
| 173 | + ->method('getWebsite') |
| 174 | + ->willReturn($websiteMock); |
| 175 | + $this->_storeManagerMock->expects($this->exactly(2)) |
| 176 | + ->method('getStore') |
| 177 | + ->with(1) |
| 178 | + ->willReturn($storeMock); |
| 179 | + $this->assertEquals('20EUR', $this->_blockCurrency->render($this->_row)); |
| 180 | + } |
141 | 181 | }
|
0 commit comments