public function testOnDeleteCascadeNotRequired() { \MoreRelationTest\PageQuery::create()->doDeleteAll(); \MoreRelationTest\ContentQuery::create()->doDeleteAll(); $page = new \MoreRelationTest\Page(); $page->setTitle('Some important Page'); $content = new \MoreRelationTest\Content(); $content->setTitle('Content'); $page->addContent($content); $page->save(); $this->assertEquals(1, \MoreRelationTest\ContentQuery::create()->count()); $page->removeContent($content); $page->save(); $this->assertEquals(0, \MoreRelationTest\ContentQuery::create()->count()); }
/** * Basic deletion of a 1-to-n relation through set<RelationName>(). * */ public function testContentsDeletion() { $contentCollection = new PropelObjectCollection(); $contentCollection->setModel('MoreRelationTest\\Content'); $content = new \MoreRelationTest\Content(); $content->setTitle('I should be alone :-('); $contentCollection[] = $content; $page = \MoreRelationTest\PageQuery::create()->findOne(); $id = $page->getId(); $count = \MoreRelationTest\ContentQuery::create()->filterByPageId($id)->count(); $this->assertEquals(3, $count, 'We created for each page 3 contents.'); $page->setContents($contentCollection); $page->save(); unset($page); $count = \MoreRelationTest\ContentQuery::create()->filterByPageId($id)->count(); $this->assertEquals(1, $count, 'We assigned a collection of only one item.'); }