8000 [TwigBridge] Fix rendering of currency by MoneyType by ro0NL · Pull Request #26663 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[TwigBridge] Fix rendering of currency by MoneyType #26663

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
tests
  • Loading branch information
ro0NL committed Mar 27, 2018
commit f128bcfde8d5dfe2bd549966685ba7928b8482df
10 changes: 3 additions & 7 deletions src/Symfony/Component/Form/Tests/AbstractLayoutTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ protected function assertMatchesXpath($html, $expression, $count = 1)
{
$dom = new \DOMDocument('UTF-8');
try {
// Wrap in <root> node so we can load HTML with multiple tags at
// the top level
$dom->loadXML('<root>'.$html.'</root>' 8000 ;);
$dom->loadHTML('<!DOCTYPE html><html><body>'.$html.'</body></html>');
} catch (\Exception $e) {
$this->fail(sprintf(
"Failed loading HTML:\n\n%s\n\nError: %s",
Expand All @@ -71,17 +69,15 @@ protected function assertMatchesXpath($html, $expression, $count = 1)
));
}
$xpath = new \DOMXPath($dom);
$nodeList = $xpath->evaluate('/root'.$expression);
$nodeList = $xpath->evaluate('/html/body'.$expression);

if ($nodeList->length != $count) {
$dom->formatOutput = true;
$this->fail(sprintf(
"Failed asserting that \n\n%s\n\nmatches exactly %s. Matches %s in \n\n%s",
$expression,
1 == $count ? 'once' : $count.' times',
1 == $nodeList->length ? 'once' : $nodeList->length.' times',
// strip away <root> and </root>
substr($dom->saveHTML(), 6, -8)
$html
));
} else {
$this->addToAssertionCount(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function testPassMoneyPatternToView()
$view = $this->factory->create(static::TESTED_TYPE)
->createView();

$this->assertSame('{{ widget }} ', $view->vars['money_pattern']);
$this->assertSame('{{ widget }} &euro;', $view->vars['money_pattern']);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These test changes look suspicious to me

Copy link
Contributor Author
@ro0NL ro0NL Mar 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah we need 2 tests for utf+iso. The entity is a direct effect of using htmlentities, and what this topic is about: euro sign not being available in ISO (hence we use entities).

}

public function testMoneyPatternWorksForYen()
Expand All @@ -43,7 +43,7 @@ public function testMoneyPatternWorksForYen()
$view = $this->factory->create(static::TESTED_TYPE, null, array('currency' => 'JPY'))
->createView();

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

// https://github.com/symfony/symfony/issues/5458
Expand All @@ -54,8 +54,8 @@ public function testPassDifferentPatternsForDifferentCurrencies()
$view1 = $this->factory->create(static::TESTED_TYPE, null, array('currency' => 'GBP'))->createView();
$view2 = $this->factory->create(static::TESTED_TYPE, null, array('currency' => 'EUR'))->createView();

$this->assertSame('{{ widget }} £', $view1->vars['money_pattern']);
$this->assertSame('{{ widget }} ', $view2->vars['money_pattern']);
$this->assertSame('{{ widget }} &pound;', $view1->vars['money_pattern']);
$this->assertSame('{{ widget }} &euro;', $view2->vars['money_pattern']);
}

public function testSubmitNull($expected = null, $norm = null, $view = null)
Expand Down
0