diff --git a/lib/Cake/Model/ModelValidator.php b/lib/Cake/Model/ModelValidator.php index 5728a79476c..18f3c975469 100644 --- a/lib/Cake/Model/ModelValidator.php +++ b/lib/Cake/Model/ModelValidator.php @@ -496,7 +496,7 @@ public function count() { * Adds a new rule to a field's rule set * * @param string $field The name of the field from wich the rule will be removed - * @param array|CakeRule $rule the rule to be added to the field's rule set + * @param array|CakeValidationRule $rule the rule to be added to the field's rule set * @return ModelValidator this instance **/ public function add($field, $name, $rule) { diff --git a/lib/Cake/Model/Validator/CakeRule.php b/lib/Cake/Model/Validator/CakeValidationRule.php similarity index 98% rename from lib/Cake/Model/Validator/CakeRule.php rename to lib/Cake/Model/Validator/CakeValidationRule.php index c65eb1271d9..d50d30ac860 100644 --- a/lib/Cake/Model/Validator/CakeRule.php +++ b/lib/Cake/Model/Validator/CakeValidationRule.php @@ -1,6 +1,6 @@ $validateProp) { - $this->_rules[$index] = new CakeRule($validateProp); + $this->_rules[$index] = new CakeValidationRule($validateProp); } $this->ruleSet = $ruleSet; } @@ -166,12 +166,12 @@ public function getRules() { * Sets a ValidationRule $rule for key $key * * @param mixed $key The key under which the rule should be set - * @param CakeRule|array $rule The validation rule to be set + * @param CakeValidationRule|array $rule The validation rule to be set * @return CakeValidationSet this instance */ public function setRule($key, $rule) { - if (!$rule instanceof CakeRule) { - $rule = new CakeRule($rule); + if (!$rule instanceof CakeValidationRule) { + $rule = new CakeValidationRule($rule); } $this->_rules[$key] = $rule; return $this; @@ -208,7 +208,7 @@ public function setRules($rules = array(), $mergeVars = true) { * Fetches the correct error message for a failed validation * * @param string $name the name of the rule as it was configured - * @param CakeRule $rule the object containing validation information + * @param CakeValidationRule $rule the object containing validation information * @return string */ protected function _processValidationResponse($name, $rule) { @@ -269,7 +269,7 @@ public function offsetExists($index) { * Returns a rule object by its index * * @param string $index name of the rule - * @return CakeRule + * @return CakeValidationRule **/ public function offsetGet($index) { return $this->_rules[$index]; @@ -279,7 +279,7 @@ public function offsetGet($index) { * Sets or replace a validation rule * * @param string $index name of the rule - * @param CakeRule|array rule to add to $index + * @param CakeValidationRule|array rule to add to $index **/ public function offsetSet($index, $rule) { $this->setRule($index, $rule); diff --git a/lib/Cake/Test/Case/Model/ModelTest.php b/lib/Cake/Test/Case/Model/ModelTest.php index 3d3714842ae..2cde6b920dd 100644 --- a/lib/Cake/Test/Case/Model/ModelTest.php +++ b/lib/Cake/Test/Case/Model/ModelTest.php @@ -35,7 +35,7 @@ public static function suite() { $suite = new PHPUnit_Framework_TestSuite('All Model related class tests'); $suite->addTestFile(CORE_TEST_CASES . DS . 'Model' . DS . 'Validator' . DS .'CakeValidationSetTest.php'); - $suite->addTestFile(CORE_TEST_CASES . DS . 'Model' . DS . 'Validator' . DS .'CakeRuleTest.php'); + $suite->addTestFile(CORE_TEST_CASES . DS . 'Model' . DS . 'Validator' . DS .'CakeValidationRuleTest.php'); $suite->addTestFile(CORE_TEST_CASES . DS . 'Model' . DS . 'ModelReadTest.php'); $suite->addTestFile(CORE_TEST_CASES . DS . 'Model' . DS . 'ModelWriteTest.php'); $suite->addTestFile(CORE_TEST_CASES . DS . 'Model' . DS . 'ModelDeleteTest.php'); diff --git a/lib/Cake/Test/Case/Model/Validator/CakeRuleTest.php b/lib/Cake/Test/Case/Model/Validator/CakeValidationRuleTest.php similarity index 87% rename from lib/Cake/Test/Case/Model/Validator/CakeRuleTest.php rename to lib/Cake/Test/Case/Model/Validator/CakeValidationRuleTest.php index e96ce641dff..c72f4969fc8 100644 --- a/lib/Cake/Test/Case/Model/Validator/CakeRuleTest.php +++ b/lib/Cake/Test/Case/Model/Validator/CakeValidationRuleTest.php @@ -1,6 +1,6 @@ process('fieldName', $data, $methods); $this->assertFalse($Rule->isValid()); @@ -94,7 +94,7 @@ public function testCustomMethods() { ); $methods = array('mytestrule' => array($this, 'myTestRule')); - $Rule = new CakeRule($def); + $Rule = new CakeValidationRule($def); $Rule->process('fieldName', $data, $methods); $this->assertFalse($Rule->isValid()); @@ -114,19 +114,19 @@ public function testCustomMethods() { */ public function testIsRequired() { $def = array('rule' => 'notEmpty', 'required' => true); - $Rule = new CakeRule($def); + $Rule = new CakeValidationRule($def); $this->assertTrue($Rule->isRequired()); $def = array('rule' => 'notEmpty', 'required' => false); - $Rule = new CakeRule($def); + $Rule = new CakeValidationRule($def); $this->assertFalse($Rule->isRequired()); $def = array('rule' => 'notEmpty', 'required' => 'create'); - $Rule = new CakeRule($def); + $Rule = new CakeValidationRule($def); $this->assertTrue($Rule->isRequired()); $def = array('rule' => 'notEmpty', 'required' => 'update'); - $Rule = new CakeRule($def); + $Rule = new CakeValidationRule($def); $this->assertFalse($Rule->isRequired()); $Rule->isUpdate(true); diff --git a/lib/Cake/Test/Case/Model/Validator/CakeValidationSetTest.php b/lib/Cake/Test/Case/Model/Validator/CakeValidationSetTest.php index 5bb66f149c1..689e3e02309 100644 --- a/lib/Cake/Test/Case/Model/Validator/CakeValidationSetTest.php +++ b/lib/Cake/Test/Case/Model/Validator/CakeValidationSetTest.php @@ -77,7 +77,7 @@ public function testGetRule() { ); $result = $Field->getRule('notEmpty'); - $this->assertInstanceOf('CakeRule', $result); + $this->assertInstanceOf('CakeValidationRule', $result); $this->assertEquals('notEmpty', $result->rule); $this->assertEquals(null, $result->required); $this->assertEquals(false, $result->allowEmpty); @@ -97,7 +97,7 @@ public function testGetRules() { $result = $Field->getRules(); $this->assertEquals(array('notEmpty'), array_keys($result)); - $this->assertInstanceOf('CakeRule', $result['notEmpty']); + $this->assertInstanceOf('CakeValidationRule', $result['notEmpty']); } /** @@ -108,23 +108,23 @@ public function testGetRules() { public function testSetRule() { $rules = array('notEmpty' => array('rule' => 'notEmpty', 'message' => 'Can not be empty')); $Field = new CakeValidationSet('title', $rules); - $Rule = new CakeRule($rules['notEmpty']); + $Rule = new CakeValidationRule($rules['notEmpty']); $this->assertEquals($Rule, $Field->getRule('notEmpty')); $rules = array('validEmail' => array('rule' => 'email', 'message' => 'Invalid email')); - $Rule = new CakeRule($rules['validEmail']); + $Rule = new CakeValidationRule($rules['validEmail']); $Field->setRule('validEmail', $Rule); $result = $Field->getRules(); $this->assertEquals(array('notEmpty', 'validEmail'), array_keys($result)); $rules = array('validEmail' => array('rule' => 'email', 'message' => 'Other message')); - $Rule = new CakeRule($rules['validEmail']); + $Rule = new CakeValidationRule($rules['validEmail']); $Field->setRule('validEmail', $Rule); $result = $Field->getRules(); $this->assertEquals(array('notEmpty', 'validEmail'), array_keys($result)); $result = $Field->getRule('validEmail'); - $this->assertInstanceOf('CakeRule', $result); + $this->assertInstanceOf('CakeValidationRule', $result); $this->assertEquals('email', $result->rule); $this->assertEquals(null, $result->required); $this->assertEquals(false, $result->allowEmpty); @@ -141,10 +141,10 @@ public function testSetRule() { public function testSetRules() { $rule = array('notEmpty' => array('rule' => 'notEmpty', 'message' => 'Can not be empty')); $Field = new CakeValidationSet('title', $rule); - $RuleEmpty = new CakeRule($rule['notEmpty']); + $RuleEmpty = new CakeValidationRule($rule['notEmpty']); $rule = array('validEmail' => array('rule' => 'email', 'message' => 'Invalid email')); - $RuleEmail = new CakeRule($rule['validEmail']); + $RuleEmail = new CakeValidationRule($rule['validEmail']); $rules = array('validEmail' => $RuleEmail); $Field->setRules($rules, false); @@ -170,15 +170,15 @@ public function testArrayAccessGet() { )); $rule = $Set['notEmpty']; - $this->assertInstanceOf('CakeRule', $rule); + $this->assertInstanceOf('CakeValidationRule', $rule); $this->assertEquals('notEmpty', $rule->rule); $rule = $Set['numeric']; - $this->assertInstanceOf('CakeRule', $rule); + $this->assertInstanceOf('CakeValidationRule', $rule); $this->assertEquals('numeric', $rule->rule); $rule = $Set['other']; - $this->assertInstanceOf('CakeRule', $rule); + $this->assertInstanceOf('CakeValidationRule', $rule); $this->assertEquals(array('other', 1), $rule->rule); } @@ -213,13 +213,13 @@ public function testArrayAccessSet() { $this->assertFalse(isset($Set['other'])); $Set['other'] = array('rule' => array('other', 1)); $rule = $Set['other']; - $this->assertInstanceOf('CakeRule', $rule); + $this->assertInstanceOf('CakeValidationRule', $rule); $this->assertEquals(array('other', 1), $rule->rule); $this->assertFalse(isset($Set['numeric'])); - $Set['numeric'] = new CakeRule(array('rule' => 'numeric')); + $Set['numeric'] = new CakeValidationRule(array('rule' => 'numeric')); $rule = $Set['numeric']; - $this->assertInstanceOf('CakeRule', $rule); + $this->assertInstanceOf('CakeValidationRule', $rule); $this->assertEquals('numeric', $rule->rule); } @@ -268,7 +268,7 @@ public function testIterator() { if ($i === 2) { $this->assertEquals('other', $name); } - $this->assertInstanceOf('CakeRule', $rule); + $this->assertInstanceOf('CakeValidationRule', $rule); $i++; } $this->assertEquals(3, $i);