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 testAddTwoCheckOrder() { $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); $content2 = new LibraryContent(); $content2->setTitleAdmin('cats'); $content2->getBodyText('cats are evil'); $content2->setTreeVersion($treeVersion); $this->em->persist($content2); $this->em->flush(); $libraryContentRepo = $this->em->getRepository('QuestionKeyBundle:LibraryContent'); $nodeHasLibraryContentRepo = $this->em->getRepository('QuestionKeyBundle:NodeHasLibraryContent'); // #################################################### TEST NO CONTENT $contentWeGot = $libraryContentRepo->findForNode($node); $this->assertEquals(0, count($contentWeGot)); // #################################################### TEST ADD FIRST $nodeHasLibraryContentRepo->addLibraryContentToNode($content1, $node); $contentWeGot = $libraryContentRepo->findForNode($node); $this->assertEquals(1, count($contentWeGot)); $this->assertEquals($content1->getId(), $contentWeGot[0]->getId()); $nodeHasLibraryContent = $nodeHasLibraryContentRepo->findOneBy(array('node' => $node, 'libraryContent' => $content1)); $this->assertNotNull($nodeHasLibraryContent); $this->assertEquals(0, $nodeHasLibraryContent->getSort()); // #################################################### TEST ADD SECOND $nodeHasLibraryContentRepo->addLibraryContentToNode($content2, $node); $contentWeGot = $libraryContentRepo->findForNode($node); $this->assertEquals(2, count($contentWeGot)); $this->assertEquals($content1->getId(), $contentWeGot[0]->getId()); $this->assertEquals($content2->getId(), $contentWeGot[1]->getId()); $nodeHasLibraryContent = $nodeHasLibraryContentRepo->findOneBy(array('node' => $node, 'libraryContent' => $content1)); $this->assertNotNull($nodeHasLibraryContent); $this->assertEquals(0, $nodeHasLibraryContent->getSort()); $nodeHasLibraryContent = $nodeHasLibraryContentRepo->findOneBy(array('node' => $node, 'libraryContent' => $content2)); $this->assertNotNull($nodeHasLibraryContent); $this->assertEquals(1, $nodeHasLibraryContent->getSort()); }