mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
adding test to disprove ticket, closes #2691
This commit is contained in:
parent
f176ae60b5
commit
4191e2e573
1 changed files with 52 additions and 0 deletions
|
@ -6560,4 +6560,56 @@ class ModelWriteTest extends BaseModelTest {
|
|||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* testSaveAllDeepHasManyBelongsTo method
|
||||
*
|
||||
* return @void
|
||||
*/
|
||||
public function testSaveAllDeepHasManyBelongsTo() {
|
||||
$this->loadFixtures('Article', 'Comment', 'User');
|
||||
$TestModel = new Article();
|
||||
$TestModel->belongsTo = $TestModel->hasAndBelongsToMany = array();
|
||||
|
||||
$this->db->truncate($TestModel);
|
||||
$this->db->truncate(new Comment());
|
||||
|
||||
$result = $TestModel->saveAll(array(
|
||||
'Article' => array('id' => 2, 'title' => 'I will not save'),
|
||||
'Comment' => array(
|
||||
array('comment' => 'First new comment', 'published' => 'Y', 'user_id' => 1),
|
||||
array(
|
||||
'comment' => 'belongsto', 'published' => 'Y',
|
||||
'User' => array('user' => 'findme', 'password' => 'somepass')
|
||||
)
|
||||
)
|
||||
), array('deep' => true));
|
||||
|
||||
$result = $TestModel->Comment->User->find('first', array(
|
||||
'conditions' => array('User.user' => 'findme'),
|
||||
'fields' => array('id', 'user', 'password')
|
||||
));
|
||||
$expected = array(
|
||||
'User' => array(
|
||||
'id' => 5,
|
||||
'user' => 'findme',
|
||||
'password' => 'somepass',
|
||||
)
|
||||
);
|
||||
$this->assertEquals($expected, $result);
|
||||
|
||||
$result = $TestModel->Comment->find('first', array(
|
||||
'conditions' => array('Comment.user_id' => 5),
|
||||
'fields' => array('id', 'comment', 'published', 'user_id')
|
||||
));
|
||||
$expected = array(
|
||||
'Comment' => array(
|
||||
'id' => 2,
|
||||
'comment' => 'belongsto',
|
||||
'published' => 'Y',
|
||||
'user_id' => 5
|
||||
)
|
||||
);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue