mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Fixes #3411, failing test when $data has more than one models data.
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5789 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
cc7d1ab74c
commit
34380bf243
2 changed files with 22 additions and 13 deletions
|
@ -824,6 +824,8 @@ class Model extends Overloadable {
|
|||
if (isset($this->validationErrors[$x])) {
|
||||
unset ($this->validationErrors[$x]);
|
||||
}
|
||||
|
||||
if ($n == $this->name || is_array($y)) {
|
||||
if ($x === $this->primaryKey) {
|
||||
$this->id = $y;
|
||||
}
|
||||
|
@ -832,6 +834,7 @@ class Model extends Overloadable {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
/**
|
||||
|
|
|
@ -999,22 +999,28 @@ class ModelTest extends CakeTestCase {
|
|||
$this->assertEqual($result, 4);
|
||||
}
|
||||
|
||||
|
||||
function testUpdateExisting() {
|
||||
$this->model =& new User();
|
||||
|
||||
$model_id = 1000;
|
||||
|
||||
$this->model->id = $model_id;
|
||||
$this->model->id = $id = 1000;
|
||||
$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('id' => $id, 'user' => 'some user')));
|
||||
$this->assertEqual($this->model->id, $id);
|
||||
|
||||
$this->model->save(array('User' => array('user' => 'updated user')));
|
||||
$this->assertEqual($this->model->id, $model_id);
|
||||
}
|
||||
$this->assertEqual($this->model->id, $id);
|
||||
|
||||
$this->Article =& new Article();
|
||||
$this->Comment =& new Comment();
|
||||
$data = array('Comment' => array('id' => 1, 'comment' => 'First Comment for First Article'),
|
||||
'Article' => array('id' => 2, 'title' => 'Second Article'));
|
||||
|
||||
$result = $this->Article->save($data);
|
||||
$this->assertTrue($result);
|
||||
|
||||
$result = $this->Comment->save($data);
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
function testBindUnbind() {
|
||||
$this->model =& new User();
|
||||
|
|
Loading…
Reference in a new issue