Removing redundant code, cleaning up some sentences

This commit is contained in:
Jose Lorenzo Rodriguez 2012-04-29 00:39:43 -04:30
parent c31f87b7a1
commit 18c26119f3
3 changed files with 2 additions and 10 deletions

View file

@ -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);
}

View file

@ -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);

View file

@ -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);
}
/**