Skip to content

Commit

Permalink
Fix hidden currency element with Bootstrap 3 theme
Browse files Browse the repository at this point in the history
  • Loading branch information
julienfalque committed Dec 2, 2017
1 parent 15482eb commit c7f28d6
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
19 changes: 19 additions & 0 deletions Tests/AbstractBootstrap3LayoutTest.php
Expand Up @@ -1899,6 +1899,25 @@ public function testMoney()
);
}

public function testMoneyWithoutCurrency()
{
$form = $this->factory->createNamed('name', 'money', 1234.56, array(
'currency' => false,
));

$this->assertWidgetMatchesXpath($form->createView(), array('id' => 'my&id', 'attr' => array('class' => 'my&class')),
'/input
[@id="my&id"]
[@type="text"]
[@name="name"]
[@class="my&class form-control"]
[@value="1234.56"]
[not(preceding-sibling::*)]
[not(following-sibling::*)]
'
);
}

public function testNumber()
{
$form = $this->factory->createNamed('name', 'number', 1234.56);
Expand Down
10 changes: 9 additions & 1 deletion Tests/Extension/Core/Type/MoneyTypeTest.php
Expand Up @@ -43,7 +43,7 @@ public function testMoneyPatternWorksForYen()
$view = $this->factory->create(static::TESTED_TYPE, null, array('currency' => 'JPY'))
->createView();

$this->assertTrue((bool) strstr($view->vars['money_pattern'], '¥'));
$this->assertSame('¥ {{ widget }}', $view->vars['money_pattern']);
}

// https://github.com/symfony/symfony/issues/5458
Expand All @@ -62,4 +62,12 @@ public function testSubmitNull($expected = null, $norm = null, $view = null)
{
parent::testSubmitNull($expected, $norm, '');
}

public function testMoneyPatternWithoutCurrency()
{
$view = $this->factory->create(static::TESTED_TYPE, null, array('currency' => false))
->createView();

$this->assertSame('{{ widget }}', $view->vars['money_pattern']);
}
}

0 comments on commit c7f28d6

Please sign in to comment.