public function testDefaultImage() { $this->assertNull($this->service->getDefaultArticleImage(self::ARTICLE_NUMBER)); $this->service->addArticleImage(self::ARTICLE_NUMBER, new LocalImage('first')); $this->assertContains('first', $this->service->getDefaultArticleImage(self::ARTICLE_NUMBER)->getPath()); $this->assertTrue($this->service->getDefaultArticleImage(self::ARTICLE_NUMBER)->isDefault()); $image = $this->service->addArticleImage(self::ARTICLE_NUMBER, new LocalImage('second')); $this->service->setDefaultArticleImage(self::ARTICLE_NUMBER, $image); $this->assertTrue($image->isDefault()); $this->assertContains('second', $this->service->getDefaultArticleImage(self::ARTICLE_NUMBER)->getPath()); }
public function testArticleRenditions() { $this->imageService->addArticleImage(self::ARTICLE_NUMBER, new LocalImage(self::PICTURE_LANDSCAPE)); $this->orm->persist($imageTest = new LocalImage(self::PICTURE_PORTRAIT)); $this->orm->flush(); $this->orm->persist($renditionThumbnail = new Rendition(200, 200, 'fit', 'thumbnail')); $this->orm->persist($renditionLandscape = new Rendition(200, 200, 'fill', 'landscape')); $this->orm->flush(); $this->assertInstanceOf('Newscoop\\Image\\ArticleRendition', $this->service->setArticleRendition(self::ARTICLE_NUMBER, $renditionLandscape, $imageTest)); $renditions = $this->service->getArticleRenditions(self::ARTICLE_NUMBER); $this->assertInstanceOf('Newscoop\\Image\\ArticleRendition', $renditions[$renditionThumbnail]); $this->assertContains(self::PICTURE_LANDSCAPE, $renditions[$renditionThumbnail]->getImage()->getPath()); $this->assertTrue($renditions[$renditionThumbnail]->isDefault()); $this->assertInstanceOf('Newscoop\\Image\\ArticleRendition', $renditions[$renditionLandscape]); $this->assertContains(self::PICTURE_PORTRAIT, $renditions[$renditionLandscape]->getImage()->getPath()); $this->assertFalse($renditions[$renditionLandscape]->isDefault()); }