/**
  * @param UuidInterface $productId
  * @param UuidInterface $tagId
  * @throws EntityNotFoundException
  */
 public function removeTag(UuidInterface $productId, UuidInterface $tagId)
 {
     $product = $this->productRepository->findOneById($productId);
     $tag = $this->tagRepository->findOneById($tagId);
     $product->removeTag($tag);
     $this->productRepository->update($product);
 }
 public function testCreateImageForTag()
 {
     $uploadFileDTO = $this->dummyData->getUploadFileDTO();
     $managedFile = $this->dummyData->getLocalManagedFile();
     $this->fileManager->shouldReceive('saveFile')->with($uploadFileDTO->getFilePath())->once()->andReturn($managedFile);
     $tag = $this->dummyData->getProduct();
     $this->tagRepository->shouldReceive('findOneById')->with($tag->getId())->andReturn($tag)->once();
     $this->imageRepository->shouldReceive('create')->once();
     $this->imageService->createImageForTag($uploadFileDTO, $tag->getId());
 }
 public function createImageForTag(UploadFileDTO $uploadFileDTO, UuidInterface $tagId)
 {
     $managedFile = $this->fileManager->saveFile($uploadFileDTO->getFilePath());
     $image = new Image();
     $image->setPath($managedFile->getUri());
     $image->setWidth($managedFile->getWidth());
     $image->setHeight($managedFile->getHeight());
     $tag = $this->tagRepository->findOneById($tagId);
     $tag->addImage($image);
     $this->create($image);
 }
 public function testRemoveTag()
 {
     $tag = $this->dummyData->getTag();
     $product = $this->dummyData->getProduct();
     $product->addTag($tag);
     $this->productRepository->shouldReceive('findOneById')->andReturn($product);
     $this->tagRepository->shouldReceive('findOneById')->andReturn($tag);
     $this->productRepository->shouldReceive('update')->once();
     $this->productService->removeTag($product->getId(), $tag->getId());
     $this->assertCount(0, $product->getTags());
 }
 public function testRemoveOption()
 {
     $tag1 = $this->dummyData->getTag();
     $this->tagRepository->shouldReceive('findOneById')->with($tag1->getId())->andReturn($tag1)->once();
     $option1 = $this->dummyData->getOption();
     $this->optionRepository->shouldReceive('findOneById')->with($option1->getId())->andReturn($option1)->once();
     $this->tagRepository->shouldReceive('update')->once();
     $this->tagService->removeOption($tag1->getId(), $option1->getId());
 }
Exemple #6
0
 public function getAllTagsByIds($tagIds, Pagination &$pagination = null)
 {
     return $this->tagRepository->getAllTagsByIds($tagIds, $pagination);
 }