diff --git a/lib/Cake/Model/ModelValidator.php b/lib/Cake/Model/ModelValidator.php index d425c7d57..c41aa24ef 100644 --- a/lib/Cake/Model/ModelValidator.php +++ b/lib/Cake/Model/ModelValidator.php @@ -18,7 +18,7 @@ * @since CakePHP(tm) v 2.2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::uses('CakeField', 'Model/Validator'); +App::uses('CakeValidationSet', 'Model/Validator'); App::uses('CakeRule', 'Model/Validator'); /** @@ -30,14 +30,7 @@ App::uses('CakeRule', 'Model/Validator'); class ModelValidator { /** - * Holds the validationErrors - * - * @var array - */ - public $validationErrors = array(); - -/** - * Holds the CakeField objects array + * Holds the CakeValidationSet objects array * * @var array */ @@ -279,7 +272,7 @@ class ModelValidator { * Gets all fields if $name is null (default), or the field for fieldname $name if it's found. * * @param string $name [optional] The fieldname to fetch. Defaults to null. - * @return mixed Either array of CakeField objects , single object for $name or false when $name not present in fields + * @return mixed Either array of CakeValidationSet objects , single object for $name or false when $name not present in fields */ public function getFields($name = null) { if ($name !== null && !empty($this->_fields[$name])) { @@ -291,7 +284,7 @@ class ModelValidator { } /** - * Sets the CakeField instances from the Model::$validate property after processing the fieldList and whiteList. + * Sets the CakeValidationSet instances from the Model::$validate property after processing the fieldList and whiteList. * If Model::$validate is not set or empty, this method returns false. True otherwise. * * @return boolean True if Model::$validate was processed, false otherwise @@ -311,7 +304,7 @@ class ModelValidator { $this->_fields = array(); $methods = $this->getMethods(); foreach ($this->_validate as $fieldName => $ruleSet) { - $this->_fields[$fieldName] = new CakeField($fieldName, $ruleSet, $methods); + $this->_fields[$fieldName] = new CakeValidationSet($fieldName, $ruleSet, $methods); } return true; } diff --git a/lib/Cake/Model/Validator/CakeRule.php b/lib/Cake/Model/Validator/CakeRule.php index f5b33253d..02bfd67e6 100644 --- a/lib/Cake/Model/Validator/CakeRule.php +++ b/lib/Cake/Model/Validator/CakeRule.php @@ -19,7 +19,7 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ App::uses('ModelValidator', 'Model'); -App::uses('CakeField', 'Model/Validator'); +App::uses('CakeValidationSet', 'Model/Validator'); App::uses('Validation', 'Utility'); /** diff --git a/lib/Cake/Model/Validator/CakeField.php b/lib/Cake/Model/Validator/CakeValidationSet.php similarity index 98% rename from lib/Cake/Model/Validator/CakeField.php rename to lib/Cake/Model/Validator/CakeValidationSet.php index 901007a68..7fb6d9c17 100644 --- a/lib/Cake/Model/Validator/CakeField.php +++ b/lib/Cake/Model/Validator/CakeValidationSet.php @@ -22,12 +22,12 @@ App::uses('ModelValidator', 'Model'); App::uses('CakeRule', 'Model/Validator'); /** - * CakeField object. + * CakeValidationSet object. * * @package Cake.Model.Validator * @link http://book.cakephp.org/2.0/en/data-validation.html */ -class CakeField { +class CakeValidationSet { /** * Holds the ValidationRule objects diff --git a/lib/Cake/Test/Case/Model/ModelTest.php b/lib/Cake/Test/Case/Model/ModelTest.php index e5e1567f2..3d3714842 100644 --- a/lib/Cake/Test/Case/Model/ModelTest.php +++ b/lib/Cake/Test/Case/Model/ModelTest.php @@ -34,7 +34,7 @@ class ModelTest extends PHPUnit_Framework_TestSuite { public static function suite() { $suite = new PHPUnit_Framework_TestSuite('All Model related class tests'); - $suite->addTestFile(CORE_TEST_CASES . DS . 'Model' . DS . 'Validator' . DS .'CakeFieldTest.php'); + $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 . 'ModelReadTest.php'); $suite->addTestFile(CORE_TEST_CASES . DS . 'Model' . DS . 'ModelWriteTest.php'); diff --git a/lib/Cake/Test/Case/Model/Validator/CakeFieldTest.php b/lib/Cake/Test/Case/Model/Validator/CakeValidationSetTest.php similarity index 87% rename from lib/Cake/Test/Case/Model/Validator/CakeFieldTest.php rename to lib/Cake/Test/Case/Model/Validator/CakeValidationSetTest.php index fdf064dbb..a68cddc3c 100644 --- a/lib/Cake/Test/Case/Model/Validator/CakeFieldTest.php +++ b/lib/Cake/Test/Case/Model/Validator/CakeValidationSetTest.php @@ -1,6 +1,6 @@ '', 'body' => 'a body' @@ -51,12 +51,12 @@ class CakeFieldTest extends CakeTestModel { $expected = array('This field cannot be left blank'); $this->assertEquals($expected, $result); - $Field = new CakeField('body', 'notEmpty'); + $Field = new CakeValidationSet('body', 'notEmpty'); $result = $Field->validate($data); $this->assertEmpty($result); - $Field = new CakeField('nothere', array('notEmpty' => array('rule' => 'notEmpty', 'required' => true))); + $Field = new CakeValidationSet('nothere', array('notEmpty' => array('rule' => 'notEmpty', 'required' => true))); $result = $Field->validate($data); $expected = array('notEmpty'); @@ -70,7 +70,7 @@ class CakeFieldTest extends CakeTestModel { */ public function testGetRule() { $rules = array('notEmpty' => array('rule' => 'notEmpty', 'message' => 'Can not be empty')); - $Field = new CakeField('title', $rules); + $Field = new CakeValidationSet('title', $rules); $data = array( 'title' => '', 'body' => 'a body' @@ -93,7 +93,7 @@ class CakeFieldTest extends CakeTestModel { */ public function testGetRules() { $rules = array('notEmpty' => array('rule' => 'notEmpty', 'message' => 'Can not be empty')); - $Field = new CakeField('title', $rules); + $Field = new CakeValidationSet('title', $rules); $result = $Field->getRules(); $this->assertEquals(array('notEmpty'), array_keys($result)); @@ -107,7 +107,7 @@ class CakeFieldTest extends CakeTestModel { */ public function testSetRule() { $rules = array('notEmpty' => array('rule' => 'notEmpty', 'message' => 'Can not be empty')); - $Field = new CakeField('title', $rules); + $Field = new CakeValidationSet('title', $rules); $Rule = new CakeRule('notEmpty', $rules['notEmpty']); $this->assertEquals($Rule, $Field->getRule('notEmpty')); @@ -140,7 +140,7 @@ class CakeFieldTest extends CakeTestModel { */ public function testSetRules() { $rule = array('notEmpty' => array('rule' => 'notEmpty', 'message' => 'Can not be empty')); - $Field = new CakeField('title', $rule); + $Field = new CakeValidationSet('title', $rule); $RuleEmpty = new CakeRule('title', $rule['notEmpty'], 'notEmpty'); $rule = array('validEmail' => array('rule' => 'email', 'message' => 'Invalid email'));