Permalink
Browse files

Adding tests for Validator

  • Loading branch information...
1 parent 324684c commit ec9966ec6bc7f03dda59bdab0bfa4eef3189e1a9 @ceeram ceeram committed Apr 23, 2012
View
@@ -979,7 +979,8 @@ protected function _createLinks() {
if (strpos($assoc, '.') !== false) {
list($plugin, $assoc) = pluginSplit($assoc, true);
- $this->{$type}[$assoc] = array('className' => $plugin . $assoc); } else {
+ $this->{$type}[$assoc] = array('className' => $plugin . $assoc);
+ } else {
$this->{$type}[$assoc] = $value;
}
}
@@ -15,7 +15,7 @@
* @copyright Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @package Cake.Model
- * @since CakePHP(tm) v 0.10.0.0
+ * @since CakePHP(tm) v 2.2.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('CakeField', 'Model/Validator');
@@ -72,7 +72,7 @@ class ModelValidator {
public $options = array();
/**
- * Holds the ModelFields
+ * Holds the CakeField objects array
*
* @var array
*/
@@ -345,17 +345,19 @@ public function getMethods($type = null) {
* 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 array|ModelField Either the fields array or the ModelField for fieldname $name
+ * @return mixed Either array of CakeField 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])) {
return $this->_fields[$name];
+ } elseif ($name !==null) {
+ return false;
}
return $this->_fields;
}
/**
- * Sets the ModelField isntances from the Model::$validate property after processing the fieldList and whiteList.
+ * Sets the CakeField isntances 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.
*
* @param boolean $reset If true will reset the Validator $validate array to the Model's default
@@ -14,62 +14,62 @@
*
* @copyright Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
- * @package Cake.Model
- * @since CakePHP(tm) v 3.0.0
+ * @package Cake.Model.Validator
+ * @since CakePHP(tm) v 2.2.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('ModelValidator', 'Model');
App::uses('CakeRule', 'Model/Validator');
/**
- * ModelField object.
+ * CakeField object.
*
- * @package Cake.Model
+ * @package Cake.Model.Validator
* @link http://book.cakephp.org/2.0/en/data-validation.html
*/
class CakeField {
/**
* Holds the parent Validator instance
- *
+ *
* @var ModelValidator
*/
protected $_validator = null;
/**
* Holds the ValidationRule objects
- *
+ *
* @var array
*/
protected $_rules = array();
/**
* If the validation is stopped
- *
+ *
* @var boolean
*/
public $isStopped = false;
/**
* Holds the fieldname
- *
+ *
* @var string
*/
public $field = null;
/**
* Holds the original ruleSet
- *
+ *
* @var array
*/
public $ruleSet = array();
/**
* Constructor
- *
+ *
* @param ModelValidator $validator The parent ModelValidator
* @param string $fieldName The fieldname
- * @param
+ * @param
*/
public function __construct(ModelValidator $validator, $fieldName, $ruleSet) {
$this->_validator = $validator;
@@ -89,7 +89,7 @@ public function __construct(ModelValidator $validator, $fieldName, $ruleSet) {
/**
* Validates a ModelField
- *
+ *
* @return mixed
*/
public function validate() {
@@ -120,7 +120,7 @@ public function validate() {
/**
* Gets a rule for a certain index
- *
+ *
* @param mixed index
* @return ValidationRule
*/
@@ -132,7 +132,7 @@ public function getRule($index) {
/**
* Gets all rules for this ModelField
- *
+ *
* @return array
*/
public function getRules() {
@@ -141,7 +141,7 @@ public function getRules() {
/**
* Sets a ValidationRule $rule for key $key
- *
+ *
* @param mixed $key The key under which the rule should be set
* @param ValidationRule $rule The ValidationRule to be set
* @return ModelField
@@ -153,7 +153,7 @@ public function setRule($key, CakeRule $rule) {
/**
* Sets the rules for a given field
- *
+ *
* @param array $rules The rules to be set
* @param bolean $mergeVars [optional] If true, merges vars instead of replace. Defaults to true.
* @return ModelField
@@ -169,7 +169,7 @@ public function setRules($rules = array(), $mergeVars = true) {
/**
* Gets the validator this field is atached to
- *
+ *
* @return ModelValidator The parent ModelValidator instance
*/
public function getValidator() {
@@ -178,7 +178,7 @@ public function getValidator() {
/**
* Magic isset
- *
+ *
* @return true if the field exists in data, false otherwise
*/
public function __isset($fieldName) {
Oops, something went wrong.

0 comments on commit ec9966e

Please sign in to comment.