Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add test for saveAssociated and expression objects.

Add a test for #1514. This issue was fixed during recent refactorings.

Closes #1514
  • Loading branch information...
commit 016c3aed44f890b8ff605b24a4392c4acd3464fa 1 parent cee2801
@markstory markstory authored
Showing with 26 additions and 0 deletions.
  1. +26 −0 lib/Cake/Test/Case/Model/ModelWriteTest.php
View
26 lib/Cake/Test/Case/Model/ModelWriteTest.php
@@ -6245,6 +6245,32 @@ public function testSaveAssociatedEmptyData() {
}
/**
+ * 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
*
* @return void
Please sign in to comment.
Something went wrong with that request. Please try again.