Ejemplo n.º 1
0
 /**
  * @param UuidInterface $tagId
  * @param UuidInterface $textOptionId
  * @throws EntityNotFoundException
  */
 public function addTextOption(UuidInterface $tagId, UuidInterface $textOptionId)
 {
     $textOption = $this->textOptionRepository->findOneById($textOptionId);
     $tag = $this->tagRepository->findOneById($tagId);
     $tag->addTextOption($textOption);
     $this->tagRepository->update($tag);
 }
Ejemplo n.º 2
0
 /**
  * @param TextOptionValueDTO[] $textOptionValueDTOs
  * @return ArrayCollection|TextOption[]
  */
 private function getTextOptionsCollection(array $textOptionValueDTOs)
 {
     $textOptionIds = [];
     foreach ($textOptionValueDTOs as $textOptionValueDTO) {
         $textOptionIds[] = $textOptionValueDTO->getTextOptionId();
     }
     $textOptions = $this->textOptionRepository->getAllTextOptionsByIds($textOptionIds);
     $textOptionCollection = new ArrayCollection();
     foreach ($textOptions as $textOption) {
         $textOptionCollection->set($textOption->getId()->getHex(), $textOption);
     }
     return $textOptionCollection;
 }
Ejemplo n.º 3
0
 public function testAddItemTextOptionValues()
 {
     $cartItem = $this->dummyData->getCartItem();
     $cart = $this->dummyData->getCart([$cartItem]);
     $textOption = $this->dummyData->getTextOption();
     $this->textOptionRepository->shouldReceive('getAllTextOptionsByIds')->andReturn([$textOption])->once();
     $textOptionValue = 'Happy Birthday';
     $textOptionValueDTO = new TextOptionValueDTO($textOption->getId()->getHex(), $textOptionValue);
     $this->cartRepository->shouldReceive('getItemById')->with($cartItem->getId())->andReturn($cartItem)->once();
     $this->cartRepositoryShouldUpdateOnce($cart);
     $this->cartService->addItemTextOptionValues($cartItem->getId(), [$textOptionValueDTO]);
     $cartItemTextOptionValue = $cart->getCartItems()[0]->getCartItemTextOptionValues()[0];
     $this->assertSame($textOptionValue, $cartItemTextOptionValue->getTextOptionValue());
     $this->assertEntitiesEqual($textOption, $cartItemTextOptionValue->getTextOption());
 }
 public function testGetAllOptionsByIds()
 {
     $originalTextOption = $this->setupOption();
     $textOptions = $this->textOptionRepository->getAllTextOptionsByIds([$originalTextOption->getId()]);
     $this->assertEntitiesEqual($originalTextOption, $textOptions[0]);
 }