Adding array cast to $check. Fixes issues when non arrays are validated with Validation::multiple. Tests added. Fixes #5986

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7974 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
mark_story 2009-01-13 18:41:04 +00:00
parent b0e23ddc7d
commit cc88680d17
2 changed files with 3 additions and 1 deletions

View file

@ -632,7 +632,7 @@ class Validation extends Object {
function multiple($check, $options = array()) {
$defaults = array('in' => null, 'max' => null, 'min' => null);
$options = array_merge($defaults, $options);
$check = array_filter($check);
$check = array_filter((array)$check);
if (empty($check)) {
return false;
}

View file

@ -1782,6 +1782,8 @@ class ValidationTestCase extends CakeTestCase {
$this->assertTrue(Validation::multiple(array(0, 1, 2, 3)));
$this->assertTrue(Validation::multiple(array(50, 32, 22, 0)));
$this->assertTrue(Validation::multiple(array('str', 'var', 'enum', 0)));
$this->assertFalse(Validation::multiple(''));
$this->assertFalse(Validation::multiple(null));
$this->assertFalse(Validation::multiple(array()));
$this->assertFalse(Validation::multiple(array(0)));
$this->assertFalse(Validation::multiple(array('0')));