8000 Merge branch '2.7' into 2.8 · symfony/symfony@fcd401f · GitHub
[go: up one dir, main page]

Skip to content

Commit fcd401f

Browse files
committed
Merge branch '2.7' into 2.8
* 2.7: Use "more entropy" option for uniqid() reset constraint options
2 parents b14c8e7 + 3902dc5 commit fcd401f

File tree

4 files changed

+36
-2
lines changed

4 files changed

+36
-2
lines changed

src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public function getProxyCandidates()
8686
$definitions = array(
8787
array(new Definition(__CLASS__), true),
8888
array(new Definition('stdClass'), true),
89-
array(new Definition('foo'.uniqid()), false),
89+
array(new Definition(uniqid('foo', true)), false),
9090
array(new Definition(), false),
9191
);
9292

src/Symfony/Bridge/Twig/Command/LintCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
110110
$template .= fread(STDIN, 1024);
111111
}
112112

113-
return $this->display($input, $output, $io, array($this->validate($twig, $template, uniqid('sf_'))));
113+
return $this->display($input, $output, $io, array($this->validate($twig, $template, uniqid('sf_', true))));
114114
}
115115

116116
$filesInfo = $this->getFilesInfo($twig, $filenames);

src/Symfony/Component/Validator/Constraint.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ public function __construct($options = null)
129129
unset($options['value']);
130130
}
131131

132+
if (is_array($options)) {
133+
reset($options);
134+
}
132135
if (is_array($options) && count($options) > 0 && is_string(key($options))) {
133136
foreach ($options as $option => $value) {
134137
if (array_key_exists($option, $knownOptions)) {

src/Symfony/Component/Validator/Tests/ConstraintTest.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,4 +206,35 @@ public function testGetErrorNameForUnknownCode()
206206
{
207207
Constraint::getErrorName(1);
208208
}
209+
210+
public function testOptionsAsDefaultOption()
211+
{
212+
$constraint = new ConstraintA($options = array('value1'));
213+
214+
$this->assertEquals($options, $constraint->property2);
215+
216+
$constraint = new ConstraintA($options = array('value1', 'property1' => 'value2'));
217+
218+
$this->assertEquals($options, $constraint->property2);
219+
}
220+
221+
/**
222+
* @expectedException \Symfony\Component\Validator\Exception\InvalidOptionsException
223+
* @expectedExceptionMessage The options "0", "5" do not exist
224+
*/
225+
public function testInvalidOptions()
226+
{
227+
new ConstraintA(array('property2' => 'foo', 'bar', 5 => 'baz'));
228+
}
229+
230+
public function testOptionsWithInvalidInternalPointer()
231+
{
232+
$options = array('property1' => 'foo');
233+
next($options);
234+
next($options);
235+
236+
$constraint = new ConstraintA($options);
237+
238+
$this->assertEquals('foo', $constraint->property1);
239+
}
209240
}

0 commit comments

Comments
 (0)
0