/**
  * Test if related files can be set
  *
  * @test
  * @return void
  */
 public function relatedFilesCanBeSet()
 {
     $file = new Tx_News_Domain_Model_File();
     $file->setTitle('fo');
     $related = new Tx_Extbase_Persistence_ObjectStorage();
     $related->attach($file);
     $this->newsDomainModelInstance->setRelatedFiles($related);
     $this->assertEquals($related, $this->newsDomainModelInstance->getRelatedFiles());
 }
 /**
  * Get related file if it exists
  *
  * @param Tx_News_Domain_Model_News $news
  * @param string $relatedFile
  * @return Boolean|Tx_News_Domain_Model_File
  */
 protected function getRelatedFileIfAlreadyExists(Tx_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;
 }