Пример #1
0
 public function testUpdateLinkInMultimediaObject()
 {
     $broadcast = $this->createBroadcast(Broadcast::BROADCAST_TYPE_PUB);
     $series = $this->factoryService->createSeries();
     $mm = $this->factoryService->createMultimediaObject($series);
     $this->assertEquals(0, count($mm->getLinks()));
     $link = new Link();
     $name = 'Original link name';
     $link->setName($name);
     $mm = $this->linkService->addLinkToMultimediaObject($mm, $link);
     $mm = $this->repoMmobj->find($mm->getId());
     $this->assertEquals(1, count($mm->getLinks()));
     $this->assertEquals($name, $mm->getLinkById($link->getId())->getName());
     $newName = 'New link name';
     $link = $mm->getLinkById($link->getId());
     $link->setName($newName);
     $mm = $this->linkService->updateLinkInMultimediaObject($mm);
     $mm = $this->repoMmobj->find($mm->getId());
     $this->assertEquals($newName, $mm->getLinkById($link->getId())->getName());
 }
Пример #2
0
 public function testGetterAndSetter()
 {
     $name = 'name';
     $locale = 'en';
     $link = new Link();
     $link->setName($name);
     $this->assertEquals($name, $link->getName());
     $nameEs = 'nombre';
     $localeEs = 'es';
     $nameI18n = array($locale => $name, $localeEs => $nameEs);
     $link->setI18nName($nameI18n);
     $this->assertEquals($nameI18n, $link->getI18nName());
     $name = null;
     $link->setName($name);
     $this->assertEquals($name, $link->getName());
 }
 public function testGetLinksWithTag()
 {
     $mm = new MultimediaObject();
     $m1 = new Link();
     $m1->setTags(array('master'));
     $m2 = new Link();
     $m2->setTags(array('mosca', 'master', 'old'));
     $m3 = new Link();
     $m3->setTags(array('master', 'mosca'));
     $m4 = new Link();
     $m4->setTags(array('flv', 'itunes', 'hide'));
     $m5 = new Link();
     $m5->setTags(array('flv', 'webtv'));
     $mm->addLink($m3);
     $mm->addLink($m2);
     $mm->addLink($m1);
     $mm->addLink($m4);
     $mm->addLink($m5);
     $this->assertEquals(array($m3, $m2, $m1), $mm->getLinksWithTag('master'));
     $this->assertEquals($m3, $mm->getLinkWithTag('master'));
     $this->assertEquals(null, $mm->getLinkWithTag('del_universo'));
     $this->assertEquals($m3, $mm->getLinkWithAnyTag(array('master', 'pr')));
     $this->assertEquals(array($m2), $mm->getLinksWithAllTags(array('master', 'mosca', 'old')));
     $this->assertTrue(in_array($mm->getLinkWithAllTags(array('mosca', 'master')), array($m3, $m2)));
     $this->assertEquals(null, $mm->getLinkWithAllTags(array('mosca', 'master', 'del_universo')));
     $this->assertEquals(4, count($mm->getLinksWithAnyTag(array('master', 'webtv'))));
     $this->assertEquals(1, count($mm->getLinkWithAnyTag(array('master'))));
     $this->assertEquals(null, $mm->getLinkWithAnyTag(array('del_universo')));
     $this->assertEquals(5, count($mm->getFilteredLinksWithTags()));
     $this->assertEquals(3, count($mm->getFilteredLinksWithTags(array('master'))));
     $this->assertEquals(1, count($mm->getFilteredLinksWithTags(array('master'), array('mosca', 'old'))));
     $this->assertEquals(0, count($mm->getFilteredLinksWithTags(array(), array('mosca', 'old'), array('master'))));
     $this->assertEquals(3, count($mm->getFilteredLinksWithTags(array(), array(), array('flv'))));
     $this->assertEquals(0, count($mm->getFilteredLinksWithTags(array(), array(), array('flv', 'master'))));
     $this->assertEquals(5, count($mm->getFilteredLinksWithTags(array(), array(), array(), array('flv', 'master'))));
     $this->assertEquals(1, count($mm->getFilteredLinksWithTags(array('mosca', 'old'), array(), array(), array('old'))));
 }