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()); }
/** * 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; }