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); }
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()); }
/** * @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); } }
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()); }
/** * @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); } }
public function findOneById(UuidInterface $id) { return $this->imageRepository->findOneById($id); }