Exemplo n.º 1
0
 public function testFindOneById()
 {
     $image1 = $this->dummyData->getTag();
     $this->imageRepository->shouldReceive('findOneById')->with($image1->getId())->andReturn($image1)->once();
     $image = $this->imageService->findOneById($image1->getId());
     $this->assertEntitiesEqual($image1, $image);
 }
Exemplo n.º 2
0
 public function testRemoveImage()
 {
     $tag1 = $this->dummyData->getTag();
     $this->tagRepository->shouldReceive('findOneById')->with($tag1->getId())->andReturn($tag1)->once();
     $image1 = $this->dummyData->getImage();
     $this->imageRepository->shouldReceive('findOneById')->with($image1->getId())->andReturn($image1)->once();
     $this->tagRepository->shouldReceive('update')->once();
     $this->imageRepository->shouldReceive('delete')->with($image1)->once();
     $this->tagService->removeImage($tag1->getId(), $image1->getId());
 }
Exemplo n.º 3
0
 /**
  * @param UuidInterface $tagId
  * @param UuidInterface $imageId
  * @throws EntityNotFoundException
  */
 public function removeImage(UuidInterface $tagId, UuidInterface $imageId)
 {
     $tag = $this->tagRepository->findOneById($tagId);
     $image = $this->imageRepository->findOneById($imageId);
     $tag->removeImage($image);
     $this->tagRepository->update($tag);
     if ($image->getProduct() === null) {
         $this->imageRepository->delete($image);
     }
 }
Exemplo n.º 4
0
 public function testRemoveImage()
 {
     $image = $this->dummyData->getImage();
     $product = $this->dummyData->getProduct();
     $product->addImage($image);
     $this->imageRepository->shouldReceive('findOneById')->andReturn($image);
     $this->productRepository->shouldReceive('findOneById')->andReturn($product);
     $this->productRepository->shouldReceive('update')->with($product)->once();
     $this->imageRepository->shouldReceive('delete')->with($image)->once();
     $this->productService->removeImage($product->getId(), $image->getId());
 }
Exemplo n.º 5
0
 /**
  * @param UuidInterface $productId
  * @param UuidInterface $imageId
  * @throws EntityNotFoundException
  */
 public function removeImage(UuidInterface $productId, UuidInterface $imageId)
 {
     $product = $this->productRepository->findOneById($productId);
     $image = $this->imageRepository->findOneById($imageId);
     $product->removeImage($image);
     $this->productRepository->update($product);
     if ($image->getTag() === null) {
         $this->imageRepository->delete($image);
     }
 }
Exemplo n.º 6
0
 public function findOneById(UuidInterface $id)
 {
     return $this->imageRepository->findOneById($id);
 }