예제 #1
0
 public function testGetterAndSetter()
 {
     $tags = array('tag_a', 'tag_b');
     $url = '/mnt/video/123/23435.mp4';
     $path = '/mnt/video/123/23435.mp4';
     $mime = 'image/jpg';
     $size = 3456;
     $width = 800;
     $height = 600;
     $hide = true;
     // Change assertTrue accordingly.
     $pic = new Pic();
     $pic->setTags($tags);
     $pic->setUrl($url);
     $pic->setPath($path);
     $pic->setMimeType($mime);
     $pic->setSize($size);
     $pic->setWidth($width);
     $pic->setHeight($height);
     $pic->setHide($hide);
     $this->assertEquals($tags, $pic->getTags());
     $this->assertEquals($url, $pic->getUrl());
     $this->assertEquals($path, $pic->getPath());
     $this->assertEquals($mime, $pic->getMimeType());
     $this->assertEquals($size, $pic->getSize());
     $this->assertEquals($width, $pic->getWidth());
     $this->assertEquals($height, $pic->getHeight());
     $this->assertTrue($pic->getHide());
 }
예제 #2
0
 /**
  * Set a pic from an url into the event
  */
 public function addPicFile(Event $event, UploadedFile $picFile)
 {
     if (UPLOAD_ERR_OK != $picFile->getError()) {
         throw new \Exception($picFile->getErrorMessage());
     }
     if (!is_file($picFile->getPathname())) {
         throw new FileNotFoundException($picFile->getPathname());
     }
     $path = $picFile->move($this->targetPath . "/" . $event->getId(), $picFile->getClientOriginalName());
     $pic = new Pic();
     $pic->setUrl(str_replace($this->targetPath, $this->targetUrl, $path));
     $pic->setPath($path);
     $event->setPic($pic);
     $this->dm->persist($event);
     $this->dm->flush();
     return $event;
 }
예제 #3
0
 /**
  * Set a pic from an url into the series
  */
 public function addPicFile(Series $series, UploadedFile $picFile, $isBanner = false, $bannerTargetUrl = "")
 {
     if (UPLOAD_ERR_OK != $picFile->getError()) {
         throw new \Exception($picFile->getErrorMessage());
     }
     if (!is_file($picFile->getPathname())) {
         throw new FileNotFoundException($picFile->getPathname());
     }
     $path = $picFile->move($this->targetPath . "/" . $series->getId(), $picFile->getClientOriginalName());
     $pic = new Pic();
     $pic->setUrl(str_replace($this->targetPath, $this->targetUrl, $path));
     $pic->setPath($path);
     if ($isBanner) {
         $pic->setHide(true);
         $pic->addTag('banner');
         $series = $this->addBanner($series, $pic->getUrl(), $bannerTargetUrl);
     }
     // TODO: add pic the latest if it is banner
     $series->addPic($pic);
     $this->dm->persist($series);
     $this->dm->flush();
     return $series;
 }
예제 #4
0
 public function testSetterAndGetter()
 {
     $live = new Live();
     $name = 'event name';
     $place = 'event place';
     $date = new \DateTime();
     $duration = '60';
     $display = 0;
     $create_serial = 0;
     $locale = 'en';
     $schedule = array('date' => $date, 'duration' => $duration);
     $pic = new Pic();
     $imagePath = '/path/to/image.jpg';
     $pic->setPath($imagePath);
     $event = new Event();
     $event->setLive($live);
     $event->setName($name);
     $event->setPlace($place);
     $event->setDate($date);
     $event->setDuration($duration);
     $event->setDisplay($display);
     $event->setCreateSerial($create_serial);
     $event->setPic($pic);
     $event->setLocale($locale);
     $event->setSchedule($schedule);
     $this->assertEquals($live, $event->getLive());
     $this->assertEquals($name, $event->getName());
     $this->assertEquals($place, $event->getPlace());
     $this->assertEquals($date, $event->getDate());
     $this->assertEquals($duration, $event->getDuration());
     $this->assertEquals($display, $event->getDisplay());
     $this->assertEquals($create_serial, $event->getCreateSerial());
     $this->assertEquals($locale, $event->getLocale());
     $this->assertEquals($pic, $event->getPic());
     $this->assertEquals($schedule, $event->getSchedule());
 }