]> git.immae.eu Git - github/wallabag/wallabag.git/blob - vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/CurrencyBundleTest.php
twig implementation
[github/wallabag/wallabag.git] / vendor / symfony / intl / Symfony / Component / Intl / Tests / ResourceBundle / CurrencyBundleTest.php
1 <?php
2
3 /*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 namespace Symfony\Component\Intl\Tests\ResourceBundle;
13
14 use Symfony\Component\Intl\ResourceBundle\CurrencyBundle;
15
16 /**
17 * @author Bernhard Schussek <bschussek@gmail.com>
18 */
19 class CurrencyBundleTest extends \PHPUnit_Framework_TestCase
20 {
21 const RES_DIR = '/base/curr';
22
23 /**
24 * @var CurrencyBundle
25 */
26 private $bundle;
27
28 /**
29 * @var \PHPUnit_Framework_MockObject_MockObject
30 */
31 private $reader;
32
33 protected function setUp()
34 {
35 $this->reader = $this->getMock('Symfony\Component\Intl\ResourceBundle\Reader\StructuredBundleReaderInterface');
36 $this->bundle = new CurrencyBundle(self::RES_DIR, $this->reader);
37 }
38
39 public function testGetCurrencySymbol()
40 {
41 $this->reader->expects($this->once())
42 ->method('readEntry')
43 ->with(self::RES_DIR, 'en', array('Currencies', 'EUR', 1))
44 ->will($this->returnValue('€'));
45
46 $this->assertSame('€', $this->bundle->getCurrencySymbol('EUR', 'en'));
47 }
48
49 public function testGetCurrencyName()
50 {
51 $this->reader->expects($this->once())
52 ->method('readEntry')
53 ->with(self::RES_DIR, 'en', array('Currencies', 'EUR', 0))
54 ->will($this->returnValue('Euro'));
55
56 $this->assertSame('Euro', $this->bundle->getCurrencyName('EUR', 'en'));
57 }
58
59 public function testGetCurrencyNames()
60 {
61 $sortedCurrencies = array(
62 'USD' => array(0 => 'Dollar'),
63 'EUR' => array(0 => 'Euro'),
64 );
65
66 $this->reader->expects($this->once())
67 ->method('readEntry')
68 ->with(self::RES_DIR, 'en', array('Currencies'))
69 ->will($this->returnValue($sortedCurrencies));
70
71 $sortedNames = array(
72 'USD' => 'Dollar',
73 'EUR' => 'Euro',
74 );
75
76 $this->assertSame($sortedNames, $this->bundle->getCurrencyNames('en'));
77 }
78
79 public function testGetFractionDigits()
80 {
81 $this->reader->expects($this->once())
82 ->method('readEntry')
83 ->with(self::RES_DIR, 'en', array('Currencies', 'EUR', 2))
84 ->will($this->returnValue(123));
85
86 $this->assertSame(123, $this->bundle->getFractionDigits('EUR'));
87 }
88
89 public function testGetRoundingIncrement()
90 {
91 $this->reader->expects($this->once())
92 ->method('readEntry')
93 ->with(self::RES_DIR, 'en', array('Currencies', 'EUR', 3))
94 ->will($this->returnValue(123));
95
96 $this->assertSame(123, $this->bundle->getRoundingIncrement('EUR'));
97 }
98 }