Ejemplo 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());
 }
Ejemplo n.º 2
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]);
 }
Ejemplo n.º 3
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());
 }