|
|
@@ -4934,6 +4934,95 @@ class ModelReadTest extends BaseModelTest {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * testAssociationAfterFindCallbacksDisabled method
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testAssociationAfterFindCalbacksDisabled() {
|
|
|
+ $this->loadFixtures('Post', 'Author', 'Comment');
|
|
|
+ $TestModel = new Post();
|
|
|
+ $result = $TestModel->find('all', array('callbacks' => false));
|
|
|
+ $expected = array(
|
|
|
+ array(
|
|
|
+ 'Post' => array(
|
|
|
+ 'id' => '1',
|
|
|
+ 'author_id' => '1',
|
|
|
+ 'title' => 'First Post',
|
|
|
+ 'body' => 'First Post Body',
|
|
|
+ 'published' => 'Y',
|
|
|
+ 'created' => '2007-03-18 10:39:23',
|
|
|
+ 'updated' => '2007-03-18 10:41:31'
|
|
|
+ ),
|
|
|
+ 'Author' => array(
|
|
|
+ 'id' => '1',
|
|
|
+ 'user' => 'mariano',
|
|
|
+ 'password' => '5f4dcc3b5aa765d61d8327deb882cf99',
|
|
|
+ 'created' => '2007-03-17 01:16:23',
|
|
|
+ 'updated' => '2007-03-17 01:18:31'
|
|
|
+ )),
|
|
|
+ array(
|
|
|
+ 'Post' => array(
|
|
|
+ 'id' => '2',
|
|
|
+ 'author_id' => '3',
|
|
|
+ 'title' => 'Second Post',
|
|
|
+ 'body' => 'Second Post Body',
|
|
|
+ 'published' => 'Y',
|
|
|
+ 'created' => '2007-03-18 10:41:23',
|
|
|
+ 'updated' => '2007-03-18 10:43:31'
|
|
|
+ ),
|
|
|
+ 'Author' => array(
|
|
|
+ 'id' => '3',
|
|
|
+ 'user' => 'larry',
|
|
|
+ 'password' => '5f4dcc3b5aa765d61d8327deb882cf99',
|
|
|
+ 'created' => '2007-03-17 01:20:23',
|
|
|
+ 'updated' => '2007-03-17 01:22:31'
|
|
|
+ )),
|
|
|
+ array(
|
|
|
+ 'Post' => array(
|
|
|
+ 'id' => '3',
|
|
|
+ 'author_id' => '1',
|
|
|
+ 'title' => 'Third Post',
|
|
|
+ 'body' => 'Third Post Body',
|
|
|
+ 'published' => 'Y',
|
|
|
+ 'created' => '2007-03-18 10:43:23',
|
|
|
+ 'updated' => '2007-03-18 10:45:31'
|
|
|
+ ),
|
|
|
+ 'Author' => array(
|
|
|
+ 'id' => '1',
|
|
|
+ 'user' => 'mariano',
|
|
|
+ 'password' => '5f4dcc3b5aa765d61d8327deb882cf99',
|
|
|
+ 'created' => '2007-03-17 01:16:23',
|
|
|
+ 'updated' => '2007-03-17 01:18:31'
|
|
|
+ )));
|
|
|
+ $this->assertEqual($expected, $result);
|
|
|
+ unset($TestModel);
|
|
|
+
|
|
|
+ $Author = new Author();
|
|
|
+ $Author->Post->bindModel(array(
|
|
|
+ 'hasMany' => array(
|
|
|
+ 'Comment' => array(
|
|
|
+ 'className' => 'ModifiedComment',
|
|
|
+ 'foreignKey' => 'article_id',
|
|
|
+ )
|
|
|
+ )));
|
|
|
+ $result = $Author->find('all', array(
|
|
|
+ 'conditions' => array('Author.id' => 1),
|
|
|
+ 'recursive' => 2,
|
|
|
+ 'callbacks' => false
|
|
|
+ ));
|
|
|
+ $expected = array(
|
|
|
+ 'id' => 1,
|
|
|
+ 'article_id' => 1,
|
|
|
+ 'user_id' => 2,
|
|
|
+ 'comment' => 'First Comment for First Article',
|
|
|
+ 'published' => 'Y',
|
|
|
+ 'created' => '2007-03-18 10:45:23',
|
|
|
+ 'updated' => '2007-03-18 10:47:31'
|
|
|
+ );
|
|
|
+ $this->assertEqual($result[0]['Post'][0]['Comment'][0], $expected);
|
|
|
+ }
|
|
|
+
|
|
|
+/**
|
|
|
* Tests that the database configuration assigned to the model can be changed using
|
|
|
* (before|after)Find callbacks
|
|
|
*
|