Skip to content

Commit

Permalink
Add test for saveAssociated and expression objects.
Browse files Browse the repository at this point in the history
Add a test for #1514. This issue was fixed during recent refactorings.

Closes #1514
  • Loading branch information
markstory committed Nov 16, 2013
1 parent cee2801 commit 016c3ae
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions lib/Cake/Test/Case/Model/ModelWriteTest.php
Expand Up @@ -6244,6 +6244,32 @@ public function testSaveAssociatedEmptyData() {
$this->assertFalse($result);
}

/**
* Test that saveAssociated will accept expression object values when saving.
*
* @return void
*/
public function testSaveAssociatedExpressionObjects() {
$this->loadFixtures('Post', 'Author', 'Comment', 'Attachment', 'Article', 'User');
$TestModel = new Post();
$db = $TestModel->getDataSource();

$TestModel->saveAssociated(array(
'Post' => array(
'title' => $db->expression('(SELECT "Post with Author")'),
'body' => 'This post will be saved with an author'
),
'Author' => array(
'user' => 'bob',
'password' => '5f4dcc3b5aa765d61d8327deb882cf90'
)));

$result = $TestModel->find('first', array(
'order' => array('Post.id ' => 'DESC')
));
$this->assertEquals('Post with Author', $result['Post']['title']);
}

/**
* testUpdateWithCalculation method
*
Expand Down

0 comments on commit 016c3ae

Please sign in to comment.