diff --git a/cake/tests/cases/libs/model/model.test.php b/cake/tests/cases/libs/model/model.test.php index 242ae233e..23b9d6916 100644 --- a/cake/tests/cases/libs/model/model.test.php +++ b/cake/tests/cases/libs/model/model.test.php @@ -84,7 +84,7 @@ var $hasAndBelongsToMany = array('Tag'); var $validate = array( 'user_id' => VALID_NUMBER, - 'title' => VALID_NOT_EMPTY, + 'title' => array('allowEmpty' => false, 'rule' => VALID_NOT_EMPTY), 'body' => VALID_NOT_EMPTY ); } @@ -1093,6 +1093,33 @@ function testRecursiveFindAllWithLimit() { $this->assertFalse($result); } + function testValidates() { + $this->model =& new Article(); + + $data = array('Article' => array('user_id' => '1', 'title' => '', 'body' => 'body')); + $result = $this->model->create($data); + $this->assertTrue($result); + $result = $this->model->validates(); + $this->assertFalse($result); + $this->assertTrue(!empty($this->model->validationErrors)); + + $data = array('Article' => array('user_id' => '1', 'title' => 'title', 'body' => 'body')); + $result = $this->model->create($data) && $this->model->validates(); + $this->assertTrue($result); + + $data = array('Article' => array('user_id' => '1', 'title' => '0', 'body' => 'body')); + $result = $this->model->create($data); + $this->assertTrue($result); + $result = $this->model->validates(); + $this->assertTrue($result); + + $data = array('Article' => array('user_id' => '1', 'title' => 0, 'body' => 'body')); + $result = $this->model->create($data); + $this->assertTrue($result); + $result = $this->model->validates(); + $this->assertTrue($result); + } + function testSave() { $this->model =& new User();