4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Intl\Tests\ResourceBundle
;
14 use Symfony\Component\Intl\ResourceBundle\CurrencyBundle
;
17 * @author Bernhard Schussek <bschussek@gmail.com>
19 class CurrencyBundleTest
extends \PHPUnit_Framework_TestCase
21 const RES_DIR
= '/base/curr';
29 * @var \PHPUnit_Framework_MockObject_MockObject
33 protected function setUp()
35 $this->reader
= $this->getMock('Symfony\Component\Intl\ResourceBundle\Reader\StructuredBundleReaderInterface');
36 $this->bundle
= new CurrencyBundle(self
::RES_DIR
, $this->reader
);
39 public function testGetCurrencySymbol()
41 $this->reader
->expects($this->once())
43 ->with(self
::RES_DIR
, 'en', array('Currencies', 'EUR', 1))
44 ->will($this->returnValue('€'));
46 $this->assertSame('€', $this->bundle
->getCurrencySymbol('EUR', 'en'));
49 public function testGetCurrencyName()
51 $this->reader
->expects($this->once())
53 ->with(self
::RES_DIR
, 'en', array('Currencies', 'EUR', 0))
54 ->will($this->returnValue('Euro'));
56 $this->assertSame('Euro', $this->bundle
->getCurrencyName('EUR', 'en'));
59 public function testGetCurrencyNames()
61 $sortedCurrencies = array(
62 'USD' => array(0 => 'Dollar'),
63 'EUR' => array(0 => 'Euro'),
66 $this->reader
->expects($this->once())
68 ->with(self
::RES_DIR
, 'en', array('Currencies'))
69 ->will($this->returnValue($sortedCurrencies));
76 $this->assertSame($sortedNames, $this->bundle
->getCurrencyNames('en'));
79 public function testGetFractionDigits()
81 $this->reader
->expects($this->once())
83 ->with(self
::RES_DIR
, 'en', array('Currencies', 'EUR', 2))
84 ->will($this->returnValue(123));
86 $this->assertSame(123, $this->bundle
->getFractionDigits('EUR'));
89 public function testGetRoundingIncrement()
91 $this->reader
->expects($this->once())
93 ->with(self
::RES_DIR
, 'en', array('Currencies', 'EUR', 3))
94 ->will($this->returnValue(123));
96 $this->assertSame(123, $this->bundle
->getRoundingIncrement('EUR'));