/** * testDeleteDependentLinks method */ public function testDeleteDependentLinks() { $totalLinks = $this->Menu->Link->find('count'); $toDelete = $this->Menu->Link->find('count', array('conditions' => array('Link.menu_id' => 4))); $this->assertTrue($toDelete > 0); $this->Menu->id = 4; $this->Menu->delete(); $count = $this->Menu->Link->find('count', array('conditions' => array('Link.menu_id' => 4))); $this->assertTrue($count == 0); $currentLinks = $this->Menu->Link->find('count'); $this->assertEquals($totalLinks, $currentLinks + $toDelete); }
/** * Test deleting a menu should not mess up other menu Link hierarchy */ public function testDeleteMenuLinkIntegrity() { $settings = array('scope' => array('Link.menu_id' => 3)); $expected = array(7 => 'Home', 8 => 'About', 9 => '_Child link', 15 => 'Contact'); $this->Menu->Link->Behaviors->Tree->setup($this->Menu->Link, $settings); $links = $this->Menu->Link->generateTreeList(array('menu_id' => 3)); $this->assertEquals($expected, $links); $this->Menu->delete(6); $this->Menu->Link->Behaviors->Tree->setup($this->Menu->Link, $settings); $links = $this->Menu->Link->generateTreeList(array('menu_id' => 3)); $this->assertEquals($expected, $links); }