mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 11:06:15 +00:00
Fixing docbloc and adding tests for FormHelper::tagIsInvalid(). Refs #2562
This commit is contained in:
parent
9c1fa28d60
commit
83e8d436f8
2 changed files with 32 additions and 7 deletions
|
@ -1434,6 +1434,31 @@ class FormHelperTest extends CakeTestCase {
|
||||||
$this->assertEquals(array(), $this->Form->fields);
|
$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
|
* testPasswordValidation method
|
||||||
*
|
*
|
||||||
|
|
|
@ -272,8 +272,8 @@ class FormHelper extends AppHelper {
|
||||||
* Returns false if given form field described by the current entity has no errors.
|
* Returns false if given form field described by the current entity has no errors.
|
||||||
* Otherwise it returns the validation message
|
* Otherwise it returns the validation message
|
||||||
*
|
*
|
||||||
* @return mixed Either false when there or no errors, or the error
|
* @return mixed Either false when there or no errors, or an array of error
|
||||||
* string. The error string could be ''.
|
* strings. An error string could be ''.
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html#FormHelper::tagIsInvalid
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html#FormHelper::tagIsInvalid
|
||||||
*/
|
*/
|
||||||
public function tagIsInvalid() {
|
public function tagIsInvalid() {
|
||||||
|
@ -289,8 +289,8 @@ class FormHelper extends AppHelper {
|
||||||
if (empty($errors)) {
|
if (empty($errors)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$error = Set::classicExtract($errors, join('.', $entity));
|
$errors = Set::classicExtract($errors, join('.', $entity));
|
||||||
return $error === null ? false : $error;
|
return $errors === null ? false : $errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue