Skip to content

Commit

Permalink
Merge branch '4.4' into 5.0
Browse files Browse the repository at this point in the history
* 4.4:
  [Cache] Use the default expiry when saving (not when creating) items
  Fix typo
  Fix DBAL deprecation
  [Form] Fix ChoiceType translation domain
  Add Tagalog translations for new form messages
  [Form] Add missing vietnamese translations
  sync translations from master
  [OptionsResolver] Fix force prepend normalizer
  add vietnamese translation for html5 color validation
  • Loading branch information
nicolas-grekas committed Jul 12, 2020
2 parents 60bce23 + 376bd3a commit 9f39c46
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions OptionsResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,7 @@ public function addNormalizer(string $option, \Closure $normalizer, bool $forceP
}

if ($forcePrepend) {
$this->normalizers[$option] = $this->normalizers[$option] ?? [];
array_unshift($this->normalizers[$option], $normalizer);
} else {
$this->normalizers[$option][] = $normalizer;
Expand Down
11 changes: 11 additions & 0 deletions Tests/OptionsResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1506,6 +1506,17 @@ public function testForcePrependNormalizerClosure()
$this->assertEquals(['foo' => '2nd-normalized-1st-normalized-bar'], $this->resolver->resolve());
}

public function testForcePrependNormalizerForResolverWithoutPreviousNormalizers()
{
// defined by superclass
$this->resolver->setDefault('foo', 'bar');
$this->resolver->addNormalizer('foo', function (Options $options, $value) {
return '1st-normalized-'.$value;
}, true);

$this->assertEquals(['foo' => '1st-normalized-bar'], $this->resolver->resolve());
}

public function testAddNormalizerFailsIfUnknownOption()
{
$this->expectException('Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException');
Expand Down

0 comments on commit 9f39c46

Please sign in to comment.