mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Adding additional tests for validation.
Added fix to model to pass the new tests git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4970 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
d1701327f8
commit
5cd13cff26
2 changed files with 13 additions and 1 deletions
|
@ -1719,7 +1719,7 @@ class Model extends Overloadable {
|
||||||
if ((!isset($data[$fieldName]) && $validator['required'] === true) || (isset($data[$fieldName]) && (empty($data[$fieldName]) && $data[$fieldName] != 0) && $validator['allowEmpty'] === false)) {
|
if ((!isset($data[$fieldName]) && $validator['required'] === true) || (isset($data[$fieldName]) && (empty($data[$fieldName]) && $data[$fieldName] != 0) && $validator['allowEmpty'] === false)) {
|
||||||
$this->invalidate($fieldName, $message);
|
$this->invalidate($fieldName, $message);
|
||||||
} elseif (isset($data[$fieldName])) {
|
} elseif (isset($data[$fieldName])) {
|
||||||
if(empty($data[$fieldName]) && $validator['allowEmpty'] === true) {
|
if(empty($data[$fieldName]) && $data[$fieldName] != '0' && $validator['allowEmpty'] === true) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (is_array($validator['rule'])) {
|
if (is_array($validator['rule'])) {
|
||||||
|
|
|
@ -1140,6 +1140,18 @@ function testRecursiveFindAllWithLimit() {
|
||||||
$this->assertTrue($result);
|
$this->assertTrue($result);
|
||||||
$result = $this->model->validates();
|
$result = $this->model->validates();
|
||||||
$this->assertFalse($result);
|
$this->assertFalse($result);
|
||||||
|
|
||||||
|
$data = array('Article' => array('user_id' => '1', 'title' => 0, 'body' => 'body', 'modified' => 0));
|
||||||
|
$result = $this->model->create($data);
|
||||||
|
$this->assertTrue($result);
|
||||||
|
$result = $this->model->validates();
|
||||||
|
$this->assertFalse($result);
|
||||||
|
|
||||||
|
$data = array('Article' => array('user_id' => '1', 'title' => 0, 'body' => 'body', 'modified' => '0'));
|
||||||
|
$result = $this->model->create($data);
|
||||||
|
$this->assertTrue($result);
|
||||||
|
$result = $this->model->validates();
|
||||||
|
$this->assertFalse($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
function testSave() {
|
function testSave() {
|
||||||
|
|
Loading…
Reference in a new issue