|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Copyright © 2015 Magento. All rights reserved. |
| 4 | + * See COPYING.txt for license details. |
| 5 | + */ |
| 6 | + |
| 7 | +namespace Magento\Directory\Test\Unit\Model; |
| 8 | + |
| 9 | +use Magento\Directory\Model\Currency; |
| 10 | + |
| 11 | +class CurrencyTest extends \PHPUnit_Framework_TestCase |
| 12 | +{ |
| 13 | + /** |
| 14 | + * @var Currency |
| 15 | + */ |
| 16 | + protected $currency; |
| 17 | + |
| 18 | + protected $currencyCode = 'USD'; |
| 19 | + |
| 20 | + /** |
| 21 | + * @var \Magento\Framework\Locale\CurrencyInterface|\PHPUnit_Framework_MockObject_MockObject |
| 22 | + */ |
| 23 | + protected $localeCurrencyMock; |
| 24 | + |
| 25 | + public function setUp() |
| 26 | + { |
| 27 | + $this->localeCurrencyMock = $this->getMock('\Magento\Framework\Locale\CurrencyInterface'); |
| 28 | + |
| 29 | + $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); |
| 30 | + $this->currency = $objectManager->getObject('Magento\Directory\Model\Currency', [ |
| 31 | + 'localeCurrency' => $this->localeCurrencyMock, |
| 32 | + 'data' => [ |
| 33 | + 'currency_code' => $this->currencyCode, |
| 34 | + ] |
| 35 | + ]); |
| 36 | + } |
| 37 | + |
| 38 | + public function testGetCurrencySymbol() |
| 39 | + { |
| 40 | + $currencySymbol = '$'; |
| 41 | + |
| 42 | + $currencyMock = $this->getMockBuilder('\Magento\Framework\Currency') |
| 43 | + ->disableOriginalConstructor() |
| 44 | + ->getMock(); |
| 45 | + $currencyMock->expects($this->once()) |
| 46 | + ->method('getSymbol') |
| 47 | + ->willReturn($currencySymbol); |
| 48 | + |
| 49 | + $this->localeCurrencyMock->expects($this->once()) |
| 50 | + ->method('getCurrency') |
| 51 | + ->with($this->currencyCode) |
| 52 | + ->willReturn($currencyMock); |
| 53 | + $this->assertEquals($currencySymbol, $this->currency->getCurrencySymbol()); |
| 54 | + } |
| 55 | +} |
0 commit comments