Esempio n. 1
0
 public function testGetterAndSetter()
 {
     $title = 'title';
     $description = 'description';
     $slug = 'slug';
     $cod = 23;
     $metatag = true;
     $created = new \DateTime("now");
     $updated = new \DateTime("now");
     $display = true;
     $youtubeProperty = "w7dD-JJJytM&list=PLmXxqSJJq-yUfrjvKe5c5LX_1x7nGVF6c";
     $properties = array('youtube' => $youtubeProperty);
     $tag = new Tag($title);
     $tag->setTitle($title);
     $tag->setDescription($description);
     $tag->setSlug($slug);
     $tag->setCod($cod);
     $tag->setMetatag($metatag);
     $tag->setCreated($created);
     $tag->setUpdated($updated);
     $tag->setDisplay($display);
     $tag->setProperties($properties);
     $tag_parent = new Tag("parent");
     $tag->setParent($tag_parent);
     $this->assertEquals($title, $tag->getTitle());
     $this->assertEquals($description, $tag->getDescription());
     $this->assertEquals($slug, $tag->getSlug());
     $this->assertEquals($cod, $tag->getCod());
     $this->assertEquals($metatag, $tag->getMetatag());
     $this->assertEquals($created, $tag->getCreated());
     $this->assertEquals($updated, $tag->getUpdated());
     $this->assertEquals($tag_parent, $tag->getParent());
     $this->assertEquals($display, $tag->getDisplay());
     $this->assertEquals($properties, $tag->getProperties());
     $this->assertEquals(null, $tag->getLockTime());
     $this->assertEquals('', $tag->getTitle('fr'));
     $this->assertEquals('', $tag->getDescription('fr'));
     $titleEs = 'título';
     $titleArray = array('en' => $title, 'es' => $titleEs);
     $descriptionEs = 'descripción';
     $descriptionArray = array('en' => $description, 'es' => $descriptionEs);
     $tag->setI18nTitle($titleArray);
     $tag->setI18nDescription($descriptionArray);
     $this->assertEquals($titleArray, $tag->getI18nTitle());
     $this->assertEquals($descriptionArray, $tag->getI18nDescription());
     $this->assertEquals($tag->getTitle(), $tag->__toString());
     $testProperty = 'test property';
     $tag->setProperty('test', $testProperty);
     $this->assertEquals($youtubeProperty, $tag->getProperty('youtube'));
     $this->assertEquals($testProperty, $tag->getProperty('test'));
     $testProperty = null;
     $tag->setProperty('test', $testProperty);
     $this->assertEquals($testProperty, $tag->getProperty('test'));
 }
 /**
  * Find by tag query builder
  *
  * @param Tag|EmbeddedTag $tag
  * @return QueryBuilder
  */
 public function findByTagCodQueryBuilder($tag)
 {
     return $this->createStandardQueryBuilder()->field('tags.cod')->equals($tag->getCod());
 }
 /**
  * Contains tag
  *
  * The original string tag logic used in_array to check it.
  * This function uses doctrine2 arrayCollection contains function instead.
  *
  * @param  Tag|EmbeddedTag $tagToCheck
  * @return boolean         TRUE if this multimedia_object contained the specified tag, FALSE otherwise.
  */
 public function containsTag($tagToCheck)
 {
     foreach ($this->tags as $tag) {
         if ($tag->getCod() == $tagToCheck->getCod()) {
             return true;
         }
     }
     return false;
 }
Esempio n. 4
0
 /**
  * Returns true if given node is descendant of tag
  *
  * @param EmbeddedTag|Tag $tag
  *
  * @return bool
  */
 public function isDescendantOf($tag)
 {
     if ($tag->getCod() == $this->getCod()) {
         return false;
     }
     return substr($this->getPath(), 0, strlen($tag->getPath())) === $tag->getPath();
 }