8000 [Form] Fix #11694 - Enforce options value type check in some form types by kix · Pull Request #11696 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Form] Fix #11694 - Enforce options value type check in some form types #11696

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[Form] Fix TimeType 'hours', 'minutes' and 'seconds' options to allow…
… only arrays
  • Loading branch information
kix committed Aug 19, 2014
commit de1786e3b11a650257c99f63f94594ecdb62a7ab
6 changes: 6 additions & 0 deletions src/Symfony/Component/Form/Extension/Core/Type/TimeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,12 @@ public function setDefaultOptions(OptionsResolverInterface $resolver)
'choice',
),
));

$resolver->setAllowedTypes(array(
'hours' => 'array',
'minutes' => 'array',
'seconds' => 'array',
));
}

/**
Expand Down
{
Original file line number Diff line number Diff line change
Expand Up @@ -673,4 +673,34 @@ public function testInitializeWithSecondsAndWithoutMinutes()
'with_seconds' => true,
));
}

/**
* @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
*/
public function testThrowExceptionIfHoursIsInvalid()
{
$this->factory->create('time', null, array(
'hours' => 'bad value',
));
}

/**
* @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
*/
public function testThrowExceptionIfMinutesIsInvalid()
{
$this->factory->create('time', null, array(
'minutes' => 'bad value',
));
}

/**
* @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
*/
public function testThrowExceptionIfSecondsIsInvalid()
$this->factory->create('time', null, array(
'seconds' => 'bad value',
));
}
}
0