Ejemplo n.º 1
0
 /**
  * Should move uploaded file to image directory
  * with resource id as filename.
  */
 public function testMovesUploadedFileUsingImageResourceID()
 {
     $upload = $this->makeMockUploadedFile();
     $upload->expects($this->atLeastOnce())->method('getClientOriginalName');
     $filename = $this->generator()->anyString();
     $this->expectImageCreation($filename);
     $upload->expects($this->atLeastOnce())->method('move')->with(storage_path('image'), $this->isType('string'));
     $this->imageRepository->storeUploadedImage($upload);
 }
Ejemplo n.º 2
0
 /**
  * @param FileBag|UploadedFile[] $images
  * @param Product                $product
  *
  * @throws \Symfony\Component\HttpFoundation\File\Exception\FileException
  */
 public function attachUploadedImagesToProduct($images, Product $product)
 {
     $product->attachImages(array_map(function (UploadedFile $image) {
         return $this->imageRepository->storeUploadedImage($image)->id;
     }, $images instanceof FileBag ? $images->all() : (array) $images));
 }