--- a/Tests/Services/DocumentServiceTest.php Mon Feb 27 11:45:38 2012 +0100
+++ b/Tests/Services/DocumentServiceTest.php Thu Mar 01 18:43:05 2012 +0100
@@ -169,6 +169,45 @@
}
+
+ public function testCopyTagsEmpty()
+ {
+ $doc_service = $this->get("wiki_tag.document");
+
+ $doc0 = $this->getDoctrine()->getRepository("CompanyBaseBundle:Document")->findOneByTitle("Title 0");
+
+ $this->assertEquals(0,count($doc_service->getTagLabels($doc0->getId())));
+
+ $doc1 = $this->getDoctrine()->getRepository("CompanyBaseBundle:Document")->findOneByTitle("Title 1");
+
+ $this->assertEquals(4,count($doc_service->getTagLabels($doc1->getId())));
+
+ $doc_service->copyTags($doc0->getId(), $doc1->getId());
+
+ $this->assertEquals(0,count($doc_service->getTagLabels($doc1->getId())));
+
+ }
+
+ public function testCopyNoPersist()
+ {
+ $doc_service = $this->get("wiki_tag.document");
+ $doc1 = $this->getDoctrine()->getRepository("CompanyBaseBundle:Document")->findOneByTitle("Title 1");
+
+ $newdoc = new \Company\BaseBundle\Entity\Document();
+ $newdoc->setTitle('a title');
+ $newdoc->setDescription('a description');
+
+ $this->getDoctrine()->getEntityManager()->persist($newdoc);
+ $this->getDoctrine()->getEntityManager()->flush();
+
+ $doc_service->copyTags($doc1->getId(), $newdoc->getId());
+
+ $this->getDoctrine()->getEntityManager()->flush();
+
+ $this->assertEquals(4,count($doc_service->getTagLabels($newdoc->getId())));
+
+ }
+
public function setUp()
{
$this->_application = new \Symfony\Bundle\FrameworkBundle\Console\Application($this->_kernel);