Adding tests for #2506

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4950 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
mariano.iglesias 2007-04-30 13:03:13 +00:00
parent 2dd02aafba
commit 01ce8392a4

View file

@ -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();