Skip to content

Commit

Permalink
Added test for deleting dependent hasMany associated records. Refs #2553
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Feb 6, 2012
1 parent 5886b25 commit 610213d
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion lib/Cake/Test/Case/Model/ModelDeleteTest.php
Expand Up @@ -555,7 +555,9 @@ public function testDeleteLinksWithPLuginJoinModel() {
* @return void
*/
public function testDeleteDependent() {
$this->loadFixtures('Bidding', 'BiddingMessage');
$this->loadFixtures('Bidding', 'BiddingMessage', 'Article',
'ArticlesTag', 'Comment', 'User', 'Attachment'
);
$Bidding = new Bidding();
$result = $Bidding->find('all');
$expected = array(
Expand Down Expand Up @@ -626,6 +628,20 @@ public function testDeleteDependent() {
),
);
$this->assertEquals($expected, $result);

$Article = new Article();
$result = $Article->Comment->find('count', array(
'conditions' => array('Comment.article_id' => 1)
));
$this->assertEquals(4, $result);

$result = $Article->delete(1, true);
$this->assertIdentical(true, true);

$result = $Article->Comment->find('count', array(
'conditions' => array('Comment.article_id' => 1)
));
$this->assertEquals(0, $result);
}

/**
Expand Down

0 comments on commit 610213d

Please sign in to comment.