Tests/Services/DocumentServiceTest.php
changeset 80 cf6a88559482
parent 67 989d9e117586
equal deleted inserted replaced
79:d98ff44275e6 80:cf6a88559482
   167         $this->assertEquals(4,count($doc_service->getTagLabels($doc2->getId())));
   167         $this->assertEquals(4,count($doc_service->getTagLabels($doc2->getId())));
   168         $this->assertEquals(array("Tag1","Tag2","Tag3","Tag4"),$doc_service->getTagLabels($doc2->getId()));
   168         $this->assertEquals(array("Tag1","Tag2","Tag3","Tag4"),$doc_service->getTagLabels($doc2->getId()));
   169         
   169         
   170     }
   170     }
   171     
   171     
       
   172     
       
   173     public function testCopyTagsEmpty()
       
   174     {
       
   175         $doc_service = $this->get("wiki_tag.document");
       
   176         
       
   177         $doc0 = $this->getDoctrine()->getRepository("CompanyBaseBundle:Document")->findOneByTitle("Title 0");
       
   178         
       
   179         $this->assertEquals(0,count($doc_service->getTagLabels($doc0->getId())));
       
   180         
       
   181         $doc1 = $this->getDoctrine()->getRepository("CompanyBaseBundle:Document")->findOneByTitle("Title 1");
       
   182         
       
   183         $this->assertEquals(4,count($doc_service->getTagLabels($doc1->getId())));
       
   184         
       
   185         $doc_service->copyTags($doc0->getId(), $doc1->getId());
       
   186         
       
   187         $this->assertEquals(0,count($doc_service->getTagLabels($doc1->getId())));
       
   188         
       
   189     }
       
   190     
       
   191     public function testCopyNoPersist()
       
   192     {
       
   193         $doc_service = $this->get("wiki_tag.document");
       
   194         $doc1 = $this->getDoctrine()->getRepository("CompanyBaseBundle:Document")->findOneByTitle("Title 1");
       
   195         
       
   196         $newdoc = new \Company\BaseBundle\Entity\Document();
       
   197         $newdoc->setTitle('a title');
       
   198         $newdoc->setDescription('a description');
       
   199 
       
   200         $this->getDoctrine()->getEntityManager()->persist($newdoc);
       
   201         $this->getDoctrine()->getEntityManager()->flush();
       
   202         
       
   203         $doc_service->copyTags($doc1->getId(), $newdoc->getId());
       
   204         
       
   205         $this->getDoctrine()->getEntityManager()->flush();
       
   206         
       
   207         $this->assertEquals(4,count($doc_service->getTagLabels($newdoc->getId())));
       
   208         
       
   209     }
       
   210     
   172     public function setUp()
   211     public function setUp()
   173     {
   212     {
   174         $this->_application = new \Symfony\Bundle\FrameworkBundle\Console\Application($this->_kernel);
   213         $this->_application = new \Symfony\Bundle\FrameworkBundle\Console\Application($this->_kernel);
   175         $this->_application->setAutoExit(false);
   214         $this->_application->setAutoExit(false);
   176         $this->runConsole("doctrine:schema:drop", array("--force" => true));
   215         $this->runConsole("doctrine:schema:drop", array("--force" => true));