Skip to content

Commit

Permalink
more tests added
Browse files Browse the repository at this point in the history
  • Loading branch information
ceeram committed Sep 23, 2012
1 parent e6b1253 commit 3ca4d23
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions lib/Cake/Test/Case/Model/ModelWriteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6399,10 +6399,10 @@ public function testSaveAllFieldListValidateBelongsTo() {

// test belongsTo
$fieldList = array(
'Post' => array('title', 'author_id'),
'Post' => array('title'),
'Author' => array('user')
);
$TestModel->saveAll(array(
$data = array(
'Post' => array(
'title' => 'Post without body',
'body' => 'This will not be saved',
Expand All @@ -6411,7 +6411,8 @@ public function testSaveAllFieldListValidateBelongsTo() {
'user' => 'bob',
'test' => 'This will not be saved',

)), array('fieldList' => $fieldList));
));
$TestModel->saveAll($data, array('fieldList' => $fieldList));

$result = $TestModel->find('all');
$expected = array(
Expand Down Expand Up @@ -6570,6 +6571,18 @@ public function testSaveAllFieldListHasOne() {
));
$this->assertTrue($result);
$this->assertEmpty($TestModel->validationErrors);

$TestModel->Attachment->whitelist = array('id');
$fieldList = array(
'Comment' => array('id', 'article_id', 'user_id'),
'Attachment' => array('id')
);
$result = $TestModel->saveAll($record, array(
'fieldList' => $fieldList
));
$this->assertTrue($result);
$result = $TestModel->find('first', array('order' => array('Comment.created' => 'DESC')));
$this->assertEquals($result['Comment']['id'], $result['Attachment']['comment_id']);
}

/**
Expand Down

0 comments on commit 3ca4d23

Please sign in to comment.