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\Form\Tests\Extension\Core\Type
;
14 use Symfony\Component\Intl\Util\IntlTestHelper
;
16 class MoneyTypeTest
extends TypeTestCase
18 protected function setUp()
20 // we test against different locales, so we need the full
22 IntlTestHelper
::requireFullIntl($this);
27 public function testPassMoneyPatternToView()
29 \Locale
::setDefault('de_DE');
31 $form = $this->factory
->create('money');
32 $view = $form->createView();
34 $this->assertSame('{{ widget }} €', $view->vars
['money_pattern']);
37 public function testMoneyPatternWorksForYen()
39 \Locale
::setDefault('en_US');
41 $form = $this->factory
->create('money', null, array('currency' => 'JPY'));
42 $view = $form->createView();
43 $this->assertTrue((Boolean
) strstr($view->vars
['money_pattern'], '¥'));
46 // https://github.com/symfony/symfony/issues/5458
47 public function testPassDifferentPatternsForDifferentCurrencies()
49 \Locale
::setDefault('de_DE');
51 $form1 = $this->factory
->create('money', null, array('currency' => 'GBP'));
52 $form2 = $this->factory
->create('money', null, array('currency' => 'EUR'));
53 $view1 = $form1->createView();
54 $view2 = $form2->createView();
56 $this->assertSame('{{ widget }} £', $view1->vars
['money_pattern']);
57 $this->assertSame('{{ widget }} €', $view2->vars
['money_pattern']);