Exemplo n.º 1
0
 public function testCreateImageForProduct()
 {
     $uploadFileDTO = $this->dummyData->getUploadFileDTO();
     $managedFile = $this->dummyData->getLocalManagedFile();
     $this->fileManager->shouldReceive('saveFile')->with($uploadFileDTO->getFilePath())->once()->andReturn($managedFile);
     $product = $this->dummyData->getProduct();
     $this->productRepository->shouldReceive('findOneById')->with($product->getId())->andReturn($product)->once();
     $this->imageRepository->shouldReceive('create')->once();
     $this->imageService->createImageForProduct($uploadFileDTO, $product->getId());
 }
Exemplo n.º 2
0
 public function createImageForProduct(UploadFileDTO $uploadFileDTO, UuidInterface $productId)
 {
     $managedFile = $this->fileManager->saveFile($uploadFileDTO->getFilePath());
     $image = new Image();
     $image->setPath($managedFile->getUri());
     $image->setWidth($managedFile->getWidth());
     $image->setHeight($managedFile->getHeight());
     $product = $this->productRepository->findOneById($productId);
     $product->addImage($image);
     $this->create($image);
 }
Exemplo n.º 3
0
 public function testGetRandomProducts()
 {
     $limit = 1;
     $product1 = $this->dummyData->getProduct();
     $this->productRepository->shouldReceive('getRandomProducts')->with($limit)->andReturn([$product1])->once();
     $products = $this->productService->getRandomProducts($limit);
     $this->assertEntitiesEqual($product1, $products[0]);
 }
Exemplo n.º 4
0
 public function testAddItem()
 {
     $product = $this->dummyData->getProduct();
     $this->productRepository->shouldReceive('findOneById')->with($product->getId())->andReturn($product)->once();
     $cart = $this->getCartThatRepositoryWillFind();
     $this->cartRepositoryShouldUpdateOnce($cart);
     $cartItemId = Uuid::uuid4();
     $cartItem = $this->cartService->addItem($cartItemId, $cart->getId(), $product->getid());
     $this->assertEntitiesEqual($cartItem, $cart->getCartItems()[0]);
     $this->assertSame(null, $cart->getShipmentRate());
 }
Exemplo n.º 5
0
 /**
  * @param UuidInterface $cartItemId
  * @param UuidInterface $cartId
  * @param UuidInterface $productId
  * @param int $quantity
  * @return CartItem
  */
 public function addItem(UuidInterface $cartItemId, UuidInterface $cartId, UuidInterface $productId, $quantity = 1)
 {
     $product = $this->productRepository->findOneById($productId);
     $cart = $this->cartRepository->findOneById($cartId);
     $cart->setShipmentRate(null);
     $cartItem = new CartItem($cartItemId);
     $cartItem->setProduct($product);
     $cartItem->setQuantity($quantity);
     $cart->addCartItem($cartItem);
     $this->cartRepository->update($cart);
     return $cartItem;
 }
Exemplo n.º 6
0
 /**
  * @param int $limit
  * @return Product[]
  */
 public function getRandomProducts($limit)
 {
     return $this->productRepository->getRandomProducts($limit);
 }
Exemplo n.º 7
0
 private function loadProductTagsFromOrderItem(OrderItem $orderItem)
 {
     $products = [$orderItem->getProduct()];
     $this->productRepository->loadProductTags($products);
 }
 public function flush()
 {
     return $this->productRepository->flush();
 }