]> git.immae.eu Git - github/wallabag/wallabag.git/blame - vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformerTest.php
gitignore vendor
[github/wallabag/wallabag.git] / vendor / symfony / form / Symfony / Component / Form / Tests / Extension / Core / DataTransformer / MoneyToLocalizedStringTransformerTest.php
CommitLineData
4f5b44bd
NL
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
12namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;
13
14use Symfony\Component\Form\Extension\Core\DataTransformer\MoneyToLocalizedStringTransformer;
15use Symfony\Component\Intl\Util\IntlTestHelper;
16
17class MoneyToLocalizedStringTransformerTest extends \PHPUnit_Framework_TestCase
18{
19 protected function setUp()
20 {
21 parent::setUp();
22
23 // Since we test against "de_AT", we need the full implementation
24 IntlTestHelper::requireFullIntl($this);
25
26 \Locale::setDefault('de_AT');
27 }
28
29 public function testTransform()
30 {
31 $transformer = new MoneyToLocalizedStringTransformer(null, null, null, 100);
32
33 $this->assertEquals('1,23', $transformer->transform(123));
34 }
35
36 public function testTransformExpectsNumeric()
37 {
38 $transformer = new MoneyToLocalizedStringTransformer(null, null, null, 100);
39
40 $this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException');
41
42 $transformer->transform('abcd');
43 }
44
45 public function testTransformEmpty()
46 {
47 $transformer = new MoneyToLocalizedStringTransformer();
48
49 $this->assertSame('', $transformer->transform(null));
50 }
51
52 public function testReverseTransform()
53 {
54 $transformer = new MoneyToLocalizedStringTransformer(null, null, null, 100);
55
56 $this->assertEquals(123, $transformer->reverseTransform('1,23'));
57 }
58
59 public function testReverseTransformExpectsString()
60 {
61 $transformer = new MoneyToLocalizedStringTransformer(null, null, null, 100);
62
63 $this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException');
64
65 $transformer->reverseTransform(12345);
66 }
67
68 public function testReverseTransformEmpty()
69 {
70 $transformer = new MoneyToLocalizedStringTransformer();
71
72 $this->assertNull($transformer->reverseTransform(''));
73 }
74}