Merge branch '2.7' into 2.8
* 2.7: Use "more entropy" option for uniqid() reset constraint options
This commit is contained in:
commit
fcd401fc9c
@ -86,7 +86,7 @@ class ProxyDumperTest extends \PHPUnit_Framework_TestCase
|
||||
$definitions = array(
|
||||
array(new Definition(__CLASS__), true),
|
||||
array(new Definition('stdClass'), true),
|
||||
array(new Definition('foo'.uniqid()), false),
|
||||
array(new Definition(uniqid('foo', true)), false),
|
||||
array(new Definition(), false),
|
||||
);
|
||||
|
||||
|
@ -110,7 +110,7 @@ EOF
|
||||
$template .= fread(STDIN, 1024);
|
||||
}
|
||||
|
||||
return $this->display($input, $output, $io, array($this->validate($twig, $template, uniqid('sf_'))));
|
||||
return $this->display($input, $output, $io, array($this->validate($twig, $template, uniqid('sf_', true))));
|
||||
}
|
||||
|
||||
$filesInfo = $this->getFilesInfo($twig, $filenames);
|
||||
|
@ -129,6 +129,9 @@ abstract class Constraint
|
||||
unset($options['value']);
|
||||
}
|
||||
|
||||
if (is_array($options)) {
|
||||
reset($options);
|
||||
}
|
||||
if (is_array($options) && count($options) > 0 && is_string(key($options))) {
|
||||
foreach ($options as $option => $value) {
|
||||
if (array_key_exists($option, $knownOptions)) {
|
||||
|
@ -206,4 +206,35 @@ class ConstraintTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
Constraint::getErrorName(1);
|
||||
}
|
||||
|
||||
public function testOptionsAsDefaultOption()
|
||||
{
|
||||
$constraint = new ConstraintA($options = array('value1'));
|
||||
|
||||
$this->assertEquals($options, $constraint->property2);
|
||||
|
||||
$constraint = new ConstraintA($options = array('value1', 'property1' => 'value2'));
|
||||
|
||||
$this->assertEquals($options, $constraint->property2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Validator\Exception\InvalidOptionsException
|
||||
* @expectedExceptionMessage The options "0", "5" do not exist
|
||||
*/
|
||||
public function testInvalidOptions()
|
||||
{
|
||||
new ConstraintA(array('property2' => 'foo', 'bar', 5 => 'baz'));
|
||||
}
|
||||
|
||||
public function testOptionsWithInvalidInternalPointer()
|
||||
{
|
||||
$options = array('property1' => 'foo');
|
||||
next($options);
|
||||
next($options);
|
||||
|
||||
$constraint = new ConstraintA($options);
|
||||
|
||||
$this->assertEquals('foo', $constraint->property1);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user