Exemple #1
5
 /**
  * Simple method to move (small) uploaded files in the filesystem
  * If the file's size is 0, it simply returns;
  * @param UploadedFile $file the file to be moved
  * @param string $path the path where to copy the file
  * @param string $newBasename the file's new basename (name without extension)
  * @throws \RuntimeException in case of errors
  * @return null
  */
 public static function writeUploadedFileToPath(UploadedFile $file, $path, $newBasename)
 {
     if (!$file->getSize()) {
         return;
     }
     $ext = pathinfo($file->getClientFilename(), PATHINFO_EXTENSION);
     $filename = $newBasename . ".{$ext}";
     $path = $path . $filename;
     file_put_contents($path, $file->getStream()->getContents());
 }
 /**
  * @depends testConstructor
  * @param UploadedFile $uploadedFile
  * @return UploadedFile
  */
 public function testGetStream(UploadedFile $uploadedFile)
 {
     $stream = $uploadedFile->getStream();
     $this->assertEquals(true, $uploadedFile->getStream() instanceof Stream);
     $stream->close();
     return $uploadedFile;
 }