public function testGetAllOptionValuesByIds()
 {
     $originalOptionValue = $this->setupOptionValue();
     $this->setCountLogger();
     $optionValues = $this->optionValueRepository->getAllOptionValuesByIds([$originalOptionValue->getId()]);
     $optionValues[0]->getOption()->getCreated();
     $this->assertEquals($originalOptionValue->getId(), $optionValues[0]->getId());
     $this->assertSame(1, $this->getTotalQueries());
 }
예제 #2
0
 public function testAddItemOptionValues()
 {
     $optionValue = $this->dummyData->getOptionValue();
     $optionValueIds = [$optionValue->getId()];
     $cartItem = $this->dummyData->getCartItem();
     $cart = $this->dummyData->getCart([$cartItem]);
     $this->optionValueRepository->shouldReceive('getAllOptionValuesByIds')->with($optionValueIds)->andReturn([$optionValue])->once();
     $this->cartRepository->shouldReceive('getItemById')->with($cartItem->getId())->andReturn($cartItem)->once();
     $this->cartRepositoryShouldUpdateOnce($cart);
     $this->cartService->addItemOptionValues($cartItem->getId(), $optionValueIds);
     $this->assertEntitiesEqual($optionValue, $cart->getCartItems()[0]->getCartItemOptionValues()[0]->getOptionValue());
 }
예제 #3
0
 /**
  * @param UuidInterface $cartItemId
  * @param UuidInterface[] $optionValueIds
  * @throws EntityNotFoundException
  */
 public function addItemOptionValues(UuidInterface $cartItemId, array $optionValueIds)
 {
     $optionValues = $this->optionValueRepository->getAllOptionValuesByIds($optionValueIds);
     $cartItem = $this->cartRepository->getItemById($cartItemId);
     $cart = $cartItem->getCart();
     foreach ($optionValues as $optionValue) {
         $cartItemOptionValue = new CartItemOptionValue();
         $cartItemOptionValue->setOptionValue($optionValue);
         $cartItem->addCartItemOptionValue($cartItemOptionValue);
     }
     $this->cartRepository->update($cart);
 }