Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch '2.1'

* 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...
commit 8e4b8082d321e936703f1cb406019efb136a1821 2 parents c1ac1d8 + 1ee199a
@fabpot fabpot authored
View
2  .gitattributes
@@ -0,0 +1,2 @@
+Tests/ export-ignore
+phpunit.xml.dist export-ignore
View
2  OptionsResolver.php
@@ -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)));
}
}
View
24 Tests/OptionsResolverTest.php
@@ -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
*/
Please sign in to comment.
Something went wrong with that request. Please try again.