Esempio n. 1
0
 /**
  * Test if related can be set
  *
  * @test
  * @return void
  */
 public function relatedFilesCanBeSet()
 {
     $file = new File();
     $file->setTitle('fo');
     $related = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
     $related->attach($file);
     $this->newsDomainModelInstance->setRelatedFiles($related);
     $this->assertEquals($related, $this->newsDomainModelInstance->getRelatedFiles());
 }
Esempio n. 2
0
 /**
  * Get related file if it exists
  *
  * @param \GeorgRinger\News\Domain\Model\News $news
  * @param string $relatedFile
  * @return Boolean|File
  */
 protected function getRelatedFileIfAlreadyExists(\GeorgRinger\News\Domain\Model\News $news, $relatedFile)
 {
     $result = FALSE;
     $relatedItems = $news->getRelatedFiles();
     if ($relatedItems->count() !== 0) {
         foreach ($relatedItems as $relatedItem) {
             if ($relatedItem->getFile() == basename($relatedFile) && $this->filesAreEqual(PATH_site . $relatedFile, PATH_site . self::UPLOAD_PATH . $relatedItem->getFile())) {
                 $result = $relatedItem;
                 break;
             }
         }
     }
     return $result;
 }