Skip to content
Permalink
Browse files

Fixing docbloc and adding tests for FormHelper::tagIsInvalid(). Refs #…

  • Loading branch information...
ADmad committed Feb 11, 2012
1 parent 9c1fa28 commit 83e8d436f815550f457fdcdbf03da8a5c9dfd68e
Showing with 32 additions and 7 deletions.
  1. +25 −0 lib/Cake/Test/Case/View/Helper/FormHelperTest.php
  2. +7 −7 lib/Cake/View/Helper/FormHelper.php
@@ -1434,6 +1434,31 @@ public function testUnlockFieldRemovingFromFields() {
$this->assertEquals(array(), $this->Form->fields);
}
/**
* testTagIsInvalid method
*
* @return void
*/
public function testTagIsInvalid() {
$Contact = ClassRegistry::getObject('Contact');
$Contact->validationErrors[0]['email'] = array('Please provide an email');
$this->Form->setEntity('Contact.0.email');
$result = $this->Form->tagIsInvalid();
$expected = array('Please provide an email');
$this->assertEquals($expected, $result);
$this->Form->setEntity('Contact.1.email');
$result = $this->Form->tagIsInvalid();
$expected = false;
$this->assertIdentical($expected, $result);
$this->Form->setEntity('Contact.0.name');
$result = $this->Form->tagIsInvalid();
$expected = false;
$this->assertIdentical($expected, $result);
}
/**
* testPasswordValidation method
*
@@ -272,8 +272,8 @@ protected function _isRequiredField($validateProperties) {
* Returns false if given form field described by the current entity has no errors.
* Otherwise it returns the validation message
*
* @return mixed Either false when there or no errors, or the error
* string. The error string could be ''.
* @return mixed Either false when there or no errors, or an array of error
* strings. An error string could be ''.
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html#FormHelper::tagIsInvalid
*/
public function tagIsInvalid() {
@@ -289,8 +289,8 @@ public function tagIsInvalid() {
if (empty($errors)) {
return false;
}
$error = Set::classicExtract($errors, join('.', $entity));
return $error === null ? false : $error;
$errors = Set::classicExtract($errors, join('.', $entity));
return $errors === null ? false : $errors;
}
/**
@@ -739,7 +739,7 @@ public function error($field, $text = null, $options = array()) {
*
* ### Options
*
* - `for` - Set the for attribute, if its not defined the for attribute
* - `for` - Set the for attribute, if its not defined the for attribute
* will be generated from the $fieldName parameter using
* FormHelper::domId().
*
@@ -776,8 +776,8 @@ public function error($field, $text = null, $options = array()) {
* }}}
*
* @param string $fieldName This should be "Modelname.fieldname"
* @param string $text Text that will appear in the label field. If
* $text is left undefined the text will be inflected from the
* @param string $text Text that will appear in the label field. If
* $text is left undefined the text will be inflected from the
* fieldName.
* @param mixed $options An array of HTML attributes, or a string, to be used as a class name.
* @return string The formatted LABEL element

0 comments on commit 83e8d43

Please sign in to comment.
You can’t perform that action at this time.