updating exists, fixes #3368, test added. thank you maular

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5733 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
gwoo 2007-10-08 17:43:14 +00:00
parent 8963c16c77
commit 356fd587cd
2 changed files with 18 additions and 2 deletions

View file

@ -1142,11 +1142,10 @@ class Model extends Overloadable {
} }
$this->afterSave($created); $this->afterSave($created);
$this->data = false; $this->data = false;
$this->__exists = null;
$this->_clearCache(); $this->_clearCache();
$this->validationErrors = array(); $this->validationErrors = array();
return true;
} }
return $success; return $success;
} }
/** /**

View file

@ -999,6 +999,23 @@ class ModelTest extends CakeTestCase {
$this->assertEqual($result, 4); $this->assertEqual($result, 4);
} }
function testUpdateExisting() {
$this->model =& new User();
$model_id = 1000;
$this->model->id = $model_id;
$this->model->delete();
$this->model->save( array('User'=>array('id'=>$model_id, 'user'=>'some user')) );
$this->assertEqual($this->model->id, $model_id);
$this->model->save( array('User'=>array('user'=>'updated user')) );
$this->assertEqual($this->model->id, $model_id);
}
function testBindUnbind() { function testBindUnbind() {
$this->model =& new User(); $this->model =& new User();