Skip to content

Commit

Permalink
Merge branch '2.1'
Browse files Browse the repository at this point in the history
* 2.1:
  fixed CS
  added doc comments
  added doc comments
  [Validator] Updated swedish translation
  Update src/Symfony/Component/Validator/Resources/translations/validators.de.xlf
  [2.1] Exclude tests from zips via gitattributes
  [HttpKernel][Translator] Fixed type-hints
  Updated lithuanian validation translation
  [DomCrawler] Allows using multiselect through Form::setValues().
  [Translation] forced the catalogue to be regenerated when a resource is added (closes symfony/translation#1)
  Unit test for patched method OptionsResolver::validateOptionValues().
  validateOptionValues throw a notice if an allowed value is set and the corresponding option isn't.
  [Form] Hardened code of ViolationMapper against errors
  [HttpFoundation] Fixed #5611 - Request::splitHttpAcceptHeader incorrect result order.
  [Form] Fixed negative index access in PropertyPathBuilder
  Update src/Symfony/Component/Validator/Resources/translations/validators.ro.xlf

Conflicts:
	src/Symfony/Component/DomCrawler/Form.php
	src/Symfony/Component/Process/Process.php
  • Loading branch information
fabpot committed Oct 6, 2012
2 parents c1ac1d8 + 1ee199a commit 8e4b808
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Tests/ export-ignore
phpunit.xml.dist export-ignore
2 changes: 1 addition & 1 deletion OptionsResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ private function validateOptionsCompleteness(array $options)
private function validateOptionValues(array $options)
{
foreach ($this->allowedValues as $option => $allowedValues) {
if (!in_array($options[$option], $allowedValues, true)) {
if (isset($options[$option]) && !in_array($options[$option], $allowedValues, true)) {
throw new InvalidOptionsException(sprintf('The option "%s" has the value "%s", but is expected to be one of "%s"', $option, $options[$option], implode('", "', $allowedValues)));
}
}
Expand Down
24 changes: 24 additions & 0 deletions Tests/OptionsResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,30 @@ public function testResolveSucceedsIfOptionValueAllowed2()
), $this->resolver->resolve($options));
}

public function testResolveSucceedsIfOptionalWithAllowedValuesNotSet()
{
$this->resolver->setRequired(array(
'one',
));

$this->resolver->setOptional(array(
'two',
));

$this->resolver->setAllowedValues(array(
'one' => array('1', 'one'),
'two' => array('2', 'two'),
));

$options = array(
'one' => '1',
);

$this->assertEquals(array(
'one' => '1',
), $this->resolver->resolve($options));
}

/**
* @expectedException Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
*/
Expand Down

0 comments on commit 8e4b808

Please sign in to comment.