From 18c26119f3f4dbc8e814c4c44fc66b607e33630f Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Sun, 29 Apr 2012 00:39:43 -0430 Subject: [PATCH] Removing redundant code, cleaning up some sentences --- lib/Cake/Model/ModelValidator.php | 2 +- lib/Cake/Model/Validator/CakeRule.php | 2 +- lib/Cake/Test/Case/Model/ModelValidationTest.php | 8 -------- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/lib/Cake/Model/ModelValidator.php b/lib/Cake/Model/ModelValidator.php index c15dfc937..37d66548e 100644 --- a/lib/Cake/Model/ModelValidator.php +++ b/lib/Cake/Model/ModelValidator.php @@ -272,7 +272,7 @@ class ModelValidator { } $methods = array(); - foreach (get_class_methods($this->_model) as $method); { + foreach (get_class_methods($this->_model) as $method) { $methods[strtolower($method)] = array($this->_model, $method); } diff --git a/lib/Cake/Model/Validator/CakeRule.php b/lib/Cake/Model/Validator/CakeRule.php index f64b34ba3..3af2591dd 100644 --- a/lib/Cake/Model/Validator/CakeRule.php +++ b/lib/Cake/Model/Validator/CakeRule.php @@ -267,7 +267,7 @@ class CakeRule { $this->_valid = call_user_func_array($methods[$rule], $this->_ruleParams); } elseif (class_exists('Validation') && method_exists('Validation', $this->_rule)) { $this->_valid = call_user_func_array(array('Validation', $this->_rule), $this->_ruleParams); - } elseif (!is_array($validator['rule'])) { + } elseif (is_string($validator['rule'])) { $this->_valid = preg_match($this->_rule, $data[$this->_field]); } elseif (Configure::read('debug') > 0) { trigger_error(__d('cake_dev', 'Could not find validation handler %s for %s', $this->_rule, $this->_field), E_USER_WARNING); diff --git a/lib/Cake/Test/Case/Model/ModelValidationTest.php b/lib/Cake/Test/Case/Model/ModelValidationTest.php index 5563a1b1d..832ff1255 100644 --- a/lib/Cake/Test/Case/Model/ModelValidationTest.php +++ b/lib/Cake/Test/Case/Model/ModelValidationTest.php @@ -32,7 +32,6 @@ class ModelValidationTest extends BaseModelTest { */ public function testValidationParams() { $TestModel = new ValidationTest1(); - $Validator = new ModelValidator($TestModel); $TestModel->validate['title'] = array( 'rule' => 'customValidatorWithParams', 'required' => true @@ -56,8 +55,6 @@ class ModelValidationTest extends BaseModelTest { 'ignoreOnSame' => 'id' ); $this->assertEquals($expected, $TestModel->validatorParams); - $Validator->invalidFields(); - $this->assertEquals($expected, $TestModel->validatorParams); $TestModel->validate['title'] = array( 'rule' => 'customValidatorWithMessage', @@ -68,7 +65,6 @@ class ModelValidationTest extends BaseModelTest { ); $this->assertEquals($expected, $TestModel->invalidFields()); - $this->assertEquals($expected, $Validator->invalidFields()); $TestModel->validate['title'] = array( 'rule' => array('customValidatorWithSixParams', 'one', 'two', null, 'four'), @@ -95,8 +91,6 @@ class ModelValidationTest extends BaseModelTest { 'six' => 6 ); $this->assertEquals($expected, $TestModel->validatorParams); - $Validator->invalidFields(); - $this->assertEquals($expected, $TestModel->validatorParams); $TestModel->validate['title'] = array( 'rule' => array('customValidatorWithSixParams', 'one', array('two'), null, 'four', array('five' => 5)), @@ -123,8 +117,6 @@ class ModelValidationTest extends BaseModelTest { ) ); $this->assertEquals($expected, $TestModel->validatorParams); - $Validator->invalidFields(); - $this->assertEquals($expected, $TestModel->validatorParams); } /**