function testPurge1()
 {
     $user = new User();
     $user->setEmail("*****@*****.**");
     $user->setUsername("test");
     $user->setPassword("ouhosu");
     $this->em->persist($user);
     $tree = new Tree();
     $tree->setTitleAdmin('Tree');
     $tree->setOwner($user);
     $tree->setPublicId('tree');
     $this->em->persist($tree);
     $treeVersion = new TreeVersion();
     $treeVersion->setTree($tree);
     $treeVersion->setPublicId('version');
     $treeVersion->setFeatureLibraryContent(true);
     $this->em->persist($treeVersion);
     $node = new Node();
     $node->setTreeVersion($treeVersion);
     $node->setPublicId('start');
     $this->em->persist($node);
     $content1 = new LibraryContent();
     $content1->setTitleAdmin('cats');
     $content1->getBodyText('cats are nice');
     $content1->setTreeVersion($treeVersion);
     $this->em->persist($content1);
     $this->em->flush();
     $nodeHasLibraryContentRepo = $this->em->getRepository('QuestionKeyBundle:NodeHasLibraryContent');
     $nodeHasLibraryContentRepo->addLibraryContentToNode($content1, $node);
     ################################ Start Purging
     $purgeTreeVersion = new PurgeTreeVersion($this->em, $treeVersion);
     $purgeTreeVersion->go();
 }
 public function go()
 {
     $tvRepo = $this->doctrine->getRepository('QuestionKeyBundle:TreeVersion');
     foreach ($tvRepo->findByTree($this->tree) as $treeVersion) {
         $purgeTreeVersion = new PurgeTreeVersion($this->doctrine, $treeVersion);
         $purgeTreeVersion->go();
     }
     $this->doctrine->remove($this->tree);
     $this->doctrine->flush($this->tree);
 }