Exemple #1
0
 /**
  * Test if correct sub selection is returned
  *
  * @test
  * @return void
  */
 public function correctMediaSelectionIsReturned()
 {
     $imageElement1 = new Media();
     $imageElement1->setType(Media::MEDIA_TYPE_IMAGE);
     $imageElement2 = new Media();
     $imageElement2->setType(Media::MEDIA_TYPE_IMAGE);
     $imageElement3 = new Media();
     $imageElement3->setType(Media::MEDIA_TYPE_IMAGE);
     $multimediaElement1 = new Media();
     $multimediaElement1->setType(Media::MEDIA_TYPE_MULTIMEDIA);
     $news = new News();
     $news->addMedia($imageElement1);
     $news->addMedia($imageElement2);
     $news->addMedia($imageElement3);
     $news->addMedia($imageElement3);
     $news->addMedia($multimediaElement1);
     $this->assertEquals(3, count($news->getMediaTypeImage()));
     $this->assertEquals(1, count($news->getMediaTypeMultimedia()));
     $this->assertEquals(4, count($news->getMedia()));
 }
Exemple #2
0
 /**
  * Get multimedia object if it exists
  *
  * @param \GeorgRinger\News\Domain\Model\News $news
  * @param string $url
  * @return Boolean|\GeorgRinger\News\Domain\Model\Media
  */
 protected function getMultiMediaIfAlreadyExists(\GeorgRinger\News\Domain\Model\News $news, $url)
 {
     $result = FALSE;
     $mediaItems = $news->getMedia();
     if (isset($mediaItem) && $mediaItems->count() !== 0) {
         foreach ($mediaItems as $mediaItem) {
             if ($mediaItem->getMultimedia() === $url) {
                 $result = $mediaItem;
                 break;
             }
         }
     }
     return $result;
 }