コード例 #1
0
 public function testEmbeddedTag()
 {
     $locale = 'en';
     $title = 'title';
     $description = 'description';
     $slug = 'slug';
     $cod = 23;
     $metatag = true;
     $created = new \DateTime("now");
     $updated = new \DateTime("now");
     $display = true;
     $tag = new Tag($title);
     $tag->setLocale($locale);
     $tag->setTitle($title);
     $tag->setDescription($description);
     $tag->setSlug($slug);
     $tag->setCod($cod);
     $tag->setMetatag($metatag);
     $tag->setCreated($created);
     $tag->setUpdated($updated);
     $tag->setDisplay($display);
     $titleEs = 'título';
     $titleArray = array('en' => $title, 'es' => $titleEs);
     $descriptionEs = 'descripción';
     $descriptionArray = array('en' => $description, 'es' => $descriptionEs);
     $tag->setI18nTitle($titleArray);
     $tag->setI18nDescription($descriptionArray);
     $mm = new MultimediaObject();
     $mm->addTag($tag);
     // TEST GETTERS
     $this->assertEquals($locale, $mm->getTags()[0]->getLocale());
     $this->assertEquals($title, $mm->getTags()[0]->getTitle());
     $this->assertEquals($description, $mm->getTags()[0]->getDescription());
     $this->assertEquals($slug, $mm->getTags()[0]->getSlug());
     $this->assertEquals($cod, $mm->getTags()[0]->getCod());
     $this->assertEquals($metatag, $mm->getTags()[0]->getMetatag());
     $this->assertEquals($created, $mm->getTags()[0]->getCreated());
     $this->assertEquals($updated, $mm->getTags()[0]->getUpdated());
     $this->assertEquals($display, $mm->getTags()[0]->getDisplay());
     $this->assertEquals($tag->getPath(), $mm->getTags()[0]->getPath());
     $this->assertEquals($tag->getLevel(), $mm->getTags()[0]->getLevel());
     $this->assertEquals('', $mm->getTags()[0]->getTitle('fr'));
     $this->assertEquals('', $mm->getTags()[0]->getDescription('fr'));
     $this->assertEquals($titleArray, $mm->getTags()[0]->getI18nTitle());
     $this->assertEquals($descriptionArray, $mm->getTags()[0]->getI18nDescription());
     $this->assertEquals($mm->getTags()[0]->getTitle(), $mm->getTags()[0]->__toString());
     // TEST SETTERS
     $title = 'modified title';
     $description = 'modified description';
     $slug = 'modified slug';
     $cod = 'modcod';
     $metatag = false;
     $created = new \DateTime("now");
     $updated = new \DateTime("now");
     $display = false;
     $mm->getTags()[0]->setTitle($title);
     $mm->getTags()[0]->setDescription($description);
     $mm->getTags()[0]->setSlug($slug);
     $mm->getTags()[0]->setCod($cod);
     $mm->getTags()[0]->setMetatag($metatag);
     $mm->getTags()[0]->setCreated($created);
     $mm->getTags()[0]->setUpdated($updated);
     $mm->getTags()[0]->setDisplay($display);
     $titleEs = 'título modificado';
     $titleArray = array('en' => $title, 'es' => $titleEs);
     $descriptionEs = 'descripción modificada';
     $descriptionArray = array('en' => $description, 'es' => $descriptionEs);
     $mm->getTags()[0]->setI18nTitle($titleArray);
     $mm->getTags()[0]->setI18nDescription($descriptionArray);
     $this->assertEquals($title, $mm->getTags()[0]->getTitle());
     $this->assertEquals($description, $mm->getTags()[0]->getDescription());
     $this->assertEquals($slug, $mm->getTags()[0]->getSlug());
     $this->assertEquals($cod, $mm->getTags()[0]->getCod());
     $this->assertEquals($metatag, $mm->getTags()[0]->getMetatag());
     $this->assertEquals($created, $mm->getTags()[0]->getCreated());
     $this->assertEquals($updated, $mm->getTags()[0]->getUpdated());
     $this->assertEquals($display, $mm->getTags()[0]->getDisplay());
     $this->assertEquals('', $mm->getTags()[0]->getTitle('fr'));
     $this->assertEquals('', $mm->getTags()[0]->getDescription('fr'));
     $this->assertEquals($titleArray, $mm->getTags()[0]->getI18nTitle());
     $this->assertEquals($descriptionArray, $mm->getTags()[0]->getI18nDescription());
     $this->assertEquals($mm->getTags()[0]->getTitle(), $mm->getTags()[0]->__toString());
     $locale = 'es';
     $mm->getTags()[0]->setLocale($locale);
     $this->assertEquals($titleEs, $mm->getTags()[0]->getTitle());
     $this->assertEquals($descriptionEs, $mm->getTags()[0]->getDescription());
 }
コード例 #2
0
 private function createTagWithTree($cod, $withROOT = true)
 {
     if ($withROOT) {
         $rootTag = $this->tagRepo->findOneByCod('ROOT');
         if (null == $rootTag) {
             $rootTag = new Tag();
             $rootTag->setCod('ROOT');
             $this->dm->persist($rootTag);
         }
     } else {
         $rootTag = $this->tagRepo->findOneByCod('grandparent');
         if (null == $rootTag) {
             $rootTag = new Tag();
             $rootTag->setCod('grandparent');
             $this->dm->persist($rootTag);
         }
     }
     $locale = 'en';
     $parentTag = $this->tagRepo->findOneByCod('parent');
     if (null == $parentTag) {
         $parentTag = new Tag();
         $parentTag->setLocale($locale);
         $parentTag->setCod('parent');
         $parentTag->setTitle('Parent');
         $parentTag->setParent($rootTag);
         $this->dm->persist($parentTag);
     }
     $tag = new Tag();
     $tag->setLocale($locale);
     $tag->setCod($cod);
     $tag->setTitle(ucfirst($cod));
     $tag->setParent($parentTag);
     $this->dm->persist($tag);
     $broTag = $this->tagRepo->findOneByCod('brother');
     if (null == $broTag) {
         $broTag = new Tag();
         $broTag->setLocale($locale);
         $broTag->setCod('brother');
         $broTag->setTitle('Brother');
         $broTag->setParent($parentTag);
         $this->dm->persist($broTag);
     }
     $this->dm->flush();
     return $tag;
 }