/**
  * Save Contribution file to file system
  * and perist Contribution info to database
  *
  * @param Contribution $contribution
  * @param \SplFileInfo $file
  */
 public function persist(Contribution $contribution, \SplFileInfo $file)
 {
     // File
     $path = $this->pathGenerator->generateAbsolutePath($contribution, $file);
     $relativePath = $this->pathGenerator->generateRelativePath($contribution, $file);
     $file->move(dirname($path), basename($path));
     // Data persistence
     $contribution->setModifiedAt(new \DateTime());
     $contribution->setFileName($relativePath);
     $this->entityManager->persist($contribution);
     $this->entityManager->flush();
 }
 /**
  * Test if generated relative path for new contribution is ok
  */
 public function testGenerateRelativePath()
 {
     $pathGenerator = new PathGenerator($this->directory);
     $path = $this->contribution->getAuthProvider() . DIRECTORY_SEPARATOR;
     $path .= $this->contribution->getIdentifier();
     $path .= '.' . $this->extension;
     $relativePath = $pathGenerator->generateRelativePath($this->contribution, $this->file);
     $this->assertEquals($relativePath, $path);
 }