public function testGetterAndSetter() { $series = new Series(); $rank = 3; $status = MultimediaObject::STATUS_PUBLISHED; $record_date = new \DateTime(); $public_date = new \DateTime(); $title = 'Star Wars'; $subtitle = 'Spoiler'; $description = "Darth Vader: Obi-Wan never told you what happened to your father.\n\t\t\tLuke Skywalker: He told me enough! He told me you killed him!\n\t\t\tDarth Vader: No. I am your father.\n\t\t\tLuke Skywalker: No... that's not true! That's impossible!"; $numview = 2; $locale = 'en'; $line2 = 'line2'; $keyword = 'keyword'; $properties = array('property1', 'property2'); $tag1 = new Tag(); $tag1->setCod('tag1'); $tag2 = new Tag(); $tag2->setCod('tag2'); $tag3 = new Tag(); $tag3->setCod('tag3'); $mm_tags = array($tag1, $tag2, $tag3); $broadcast = new Broadcast(); $broadcast->setName('Private'); $broadcast->setBroadcastTypeId(Broadcast::BROADCAST_TYPE_PRI); $broadcast->setPasswd('password'); $broadcast->setDefaultSel(true); $broadcast->setDescription('Private broadcast'); $mm = new MultimediaObject(); $mm->setRank($rank); $mm->setStatus($status); $mm->setSeries($series); $mm->setRecordDate($record_date); $mm->setPublicDate($public_date); $mm->setTitle($title); $mm->setSubtitle($subtitle); $mm->setDescription($description); $mm->addTag($tag1); $mm->addTag($tag2); $mm->addTag($tag3); $mm->setBroadcast($broadcast); $mm->setNumview($numview); $mm->setLocale($locale); $mm->setLine2($line2); $mm->setKeyword($keyword); $mm->setProperties($properties); $this->assertEquals($series, $mm->getSeries()); $this->assertEquals($rank, $mm->getRank()); $this->assertEquals($status, $mm->getStatus()); $this->assertEquals($record_date, $mm->getRecordDate()); $this->assertEquals($public_date, $mm->getPublicDate()); $this->assertEquals($title, $mm->getTitle()); $this->assertNotEquals($title . "2", $mm->getTitle()); $this->assertEquals($subtitle, $mm->getSubtitle()); $this->assertEquals($description, $mm->getDescription()); $this->assertEquals(count($mm_tags), count($mm->getTags())); $this->assertEquals($broadcast, $mm->getBroadcast()); $this->assertEquals($numview, $mm->getNumview()); $this->assertEquals($locale, $mm->getLocale()); $this->assertEquals($line2, $mm->getLine2()); $this->assertEquals($keyword, $mm->getKeyword()); $this->assertEquals($properties, $mm->getProperties()); $title = null; $subtitle = null; $description = null; $line2 = null; $keyword = null; $mm->setTitle($title); $mm->setSubtitle($subtitle); $mm->setDescription($description); $mm->setLine2($line2); $mm->setKeyword($keyword); $this->assertEquals(null, $mm->getTitle()); $this->assertEquals(null, $mm->getSubtitle()); $this->assertEquals(null, $mm->getDescription()); $this->assertEquals(null, $mm->getLine2()); $this->assertEquals(null, $mm->getKeyword()); $properties = array('prop2' => 'property2'); $mm->setProperties($properties); $key = 'prop2'; $this->assertEquals($properties[$key], $mm->getProperty($key)); $property3 = 'property3'; $value3 = 'value3'; $mm->setProperty($property3, $value3); $this->assertEquals($value3, $mm->getProperty($property3)); $mm->removeProperty($property3); $this->assertNull($mm->getProperty($property3)); }
/** * Clone a multimedia object. * * @param MultimediaObject $src * @return MultimediaObject */ public function cloneMultimediaObject(MultimediaObject $src) { $new = new MultimediaObject(); $new->setI18nTitle($src->getI18nTitle()); $new->setI18nSubtitle($src->getI18nSubtitle()); $new->setI18nDescription($src->getI18nDescription()); $new->setI18nLine2($src->getI18nLine2()); $new->setI18nKeyword($src->getI18nKeyword()); $new->setCopyright($src->getCopyright()); $new->setLicense($src->getLicense()); // NOTE: #7408 Specify which properties are clonable $new->setProperty("subseries", $src->getProperty("subseries")); $new->setProperty("subseriestitle", $src->getProperty("subseriestitle")); $new->setProperty("clonedfrom", $src->getId()); foreach ($src->getTags() as $tag) { $tagAdded = $this->tagService->addTagToMultimediaObject($new, $tag->getId(), false); } foreach ($src->getRoles() as $embeddedRole) { foreach ($embeddedRole->getPeople() as $embeddedPerson) { $new->addPersonWithRole($embeddedPerson, $embeddedRole); } } $new->setSeries($src->getSeries()); if ($broadcast = $src->getBroadcast()) { $new->setBroadcast($broadcast); $this->dm->persist($broadcast); } $new->setPublicDate($src->getPublicDate()); $new->setRecordDate($src->getRecordDate()); $new->setStatus(MultimediaObject::STATUS_BLOQ); $this->dm->persist($new); $this->dm->flush(); return $new; }