Ejemplo n.º 1
0
 /**
  * Make sure files are \Illuminate\Http\UploadedFile instances with the private $test property set to true.
  * Fixes issue https://github.com/Codeception/Codeception/pull/3417.
  *
  * @param array $files
  * @return array
  */
 protected function filterFiles(array $files)
 {
     $files = parent::filterFiles($files);
     if (!class_exists('Illuminate\\Http\\UploadedFile')) {
         // The \Illuminate\Http\UploadedFile class was introduced in Laravel 5.2.15,
         // so don't change the $files array if it does not exist.
         return $files;
     }
     $filtered = [];
     foreach ($files as $key => $file) {
         $filtered[$key] = UploadedFile::createFromBase($file, true);
     }
     return $filtered;
 }
Ejemplo n.º 2
0
 /**
  * Convert the given array of Symfony UploadedFiles to custom Laravel UploadedFiles.
  *
  * @param  array  $files
  * @return array
  */
 protected function convertUploadedFiles(array $files)
 {
     return array_map(function ($file) {
         if (is_null($file) || is_array($file) && empty(array_filter($file))) {
             return $file;
         }
         return is_array($file) ? $this->convertUploadedFiles($file) : UploadedFile::createFromBase($file);
     }, $files);
 }
Ejemplo n.º 3
0
 /**
  * Convert the given array of Symfony UploadedFiles to custom Laravel UploadedFiles.
  *
  * @param  array  $files
  * @return array
  */
 protected function convertUploadedFiles(array $files)
 {
     return array_map(function ($file) {
         return is_array($file) ? $this->convertUploadedFiles($file) : UploadedFile::createFromBase($file);
     }, $files);
 }