예제 #1
0
 /**
  * @param int                    $imageId
  * @param PutImageAltTextRequest $request
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function putImageAltText(int $imageId, PutImageAltTextRequest $request)
 {
     $image = $this->imageRepository->loadById($imageId);
     $image->alt_text = $request->altText();
     $image->save();
     $this->webUi->successMessage("Set the alt text for image {$image->id} to {$request->altText()}.");
     return $this->redirectToImagesIndex();
 }
예제 #2
0
 /**
  * Should be able to trigger events to transfer local images.
  */
 public function testTransferLocalImages()
 {
     $image = $this->makeMock(Image::class);
     $this->imageResource->shouldReceive('orWhere->get')->atLeast()->once()->andReturn(new Collection([$image]));
     $this->dispatcher->expects($this->atLeastOnce())->method('fire')->with($this->callback(function (NewImageEvent $event) use($image) {
         $this->assertSame($image, $event->image());
         return true;
     }));
     $this->imageRepository->transferLocalImages();
 }
 /**
  * @param MockInterface $storeProductRequest
  */
 private function mockNewImageUpload(MockInterface $storeProductRequest)
 {
     $storeProductRequest->shouldReceive('hasFile')->with(NewImagesRequest::PARAMETER)->andReturn($this->generator()->anyBoolean());
     $storeProductRequest->shouldReceive('file')->with('new-image')->andReturn([]);
     $this->imageRepository->shouldReceive('attachUploadedImagesToProduct');
 }
예제 #4
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));
 }
예제 #5
0
 /**
  * Should be able to request that local images are transferred to cloud
  * storage.
  */
 public function testTransferLocalImages()
 {
     $this->imageRepository->expects($this->atLeastOnce())->method('transferLocalImages');
     $this->imageController->transferLocalImages();
 }