예제 #1
0
 /**
  * @param int $price
  * @param int $quantity
  * @param string $sku
  *
  * @return \Generated\Shared\Transfer\ItemTransfer
  */
 protected function createItemTransfer($price = 0, $quantity = 0, $sku = '')
 {
     $itemTransfer = new ItemTransfer();
     $itemTransfer->setUnitGrossPrice($price);
     $itemTransfer->setQuantity($quantity);
     $itemTransfer->setSku($sku);
     return $itemTransfer;
 }
예제 #2
0
 /**
  * @return void
  */
 public function testDecreaseCartItem()
 {
     $this->markTestSkipped('Tried to retrieve a concrete product with sku CONCRETE1, but it does not exist');
     $quoteTransfer = new QuoteTransfer();
     $cartItem = new ItemTransfer();
     $cartItem->setSku(self::DUMMY_1_SKU_CONCRETE_PRODUCT);
     $cartItem->setQuantity(3);
     $cartItem->setUnitGrossPrice(1);
     $quoteTransfer->addItem($cartItem);
     $newItem = new ItemTransfer();
     $newItem->setSku(self::DUMMY_1_SKU_CONCRETE_PRODUCT);
     $newItem->setQuantity(1);
     $newItem->setUnitGrossPrice(1);
     $cartChange = new CartChangeTransfer();
     $cartChange->setQuote($quoteTransfer);
     $cartChange->addItem($newItem);
     $changedCart = $this->cartFacade->decreaseQuantity($cartChange);
     $cartItems = $changedCart->getItems();
     $this->assertCount(1, $cartItems);
     /** @var \Generated\Shared\Transfer\ItemTransfer $changedItem */
     $changedItem = $cartItems[0];
     $this->assertEquals(2, $changedItem->getQuantity());
 }
예제 #3
0
 /**
  * @return void
  */
 public function testChangeItemQuantityMustCallAddItemQuantityWhenPassedItemQuantityIsLowerThenInCartGivenItem()
 {
     $itemTransfer = new ItemTransfer();
     $itemTransfer->setQuantity(1);
     $itemTransfer->setSku('sku');
     $quoteTransfer = new QuoteTransfer();
     $quoteTransfer->addItem($itemTransfer);
     $sessionMock = $this->getSessionMock();
     $sessionMock->expects($this->exactly(3))->method('getQuote')->will($this->returnValue($quoteTransfer));
     $stubMock = $this->getStubMock();
     $stubMock->expects($this->never())->method('removeItem')->will($this->returnValue($quoteTransfer));
     $stubMock->expects($this->once())->method('addItem')->will($this->returnValue($quoteTransfer));
     $factoryMock = $this->getFactoryMock($sessionMock, $stubMock);
     $cartClientMock = $this->getCartClientMock($factoryMock);
     $itemTransfer = new ItemTransfer();
     $itemTransfer->setSku('sku');
     $quoteTransfer = $cartClientMock->changeItemQuantity('sku', null, 2);
     $this->assertInstanceOf('Generated\\Shared\\Transfer\\QuoteTransfer', $quoteTransfer);
 }
예제 #4
0
 /**
  * @return void
  */
 public function testRemoveItem()
 {
     $wishlist = new WishlistTransfer();
     $customerTransfer = new CustomerTransfer();
     $customerTransfer->setIdCustomer(1);
     $sypWishlist = new WishlistSpy();
     $sypWishlist->setFkCustomer(1);
     $spyWishlistItem = new WishlistItemSpy();
     $spyWishlistItem->setQuantity(3);
     $spyWishlistItem->setFkProductAbstract(1);
     $spyWishlistItem->setFkProduct(1);
     $spyWishlistItem->setGroupKey(123);
     $propelStorage = new Propel($this->getWishlistQueryContainerMock($sypWishlist, $spyWishlistItem), $this->getCustomerMock(), $wishlist, $customerTransfer, $this->getProductFacadeMock());
     $wishlistChange = new WishlistChangeTransfer();
     $wishlistItem = new ItemTransfer();
     $wishlistItem->setGroupKey('123');
     $wishlistItem->setQuantity(0);
     $wishlistChange->addItem($wishlistItem);
     $propelStorage->removeItems($wishlistChange);
     $this->assertTrue($spyWishlistItem->isDelete());
 }
예제 #5
0
 /**
  * @return void
  */
 public function testIncreaseItem()
 {
     $productFacadeMock = $this->createProductFacadeProductConcreteMock();
     $wishlistTransfer = new WishlistTransfer();
     $wishlistItem = new ItemTransfer();
     $wishlistItem->setGroupKey(123);
     $wishlistItem->setQuantity(1);
     $wishlistTransfer->addItem($wishlistItem);
     $inMemory = new InMemory($wishlistTransfer, $productFacadeMock);
     $wishlistChangeTransfer = new WishlistChangeTransfer();
     $wishlistItem = new ItemTransfer();
     $wishlistItem->setGroupKey(123);
     $wishlistItem->setQuantity(1);
     $wishlistChangeTransfer->addItem($wishlistItem);
     $wishlist = $inMemory->increaseItems($wishlistChangeTransfer);
     $wishlistItem = $wishlist->getItems()[0];
     $this->assertEquals(2, $wishlistItem->getQuantity());
 }
예제 #6
0
 /**
  * @param string $itemId
  * @param int $itemQuantity
  *
  * @return \Generated\Shared\Transfer\ItemTransfer|\Generated\Shared\Transfer\ItemTransfer|\Spryker\Shared\Transfer\AbstractTransfer
  */
 protected function createItem($itemId, $itemQuantity)
 {
     $existingItem = new ItemTransfer();
     $existingItem->setId($itemId);
     $existingItem->setSku($itemId);
     $existingItem->setQuantity($itemQuantity);
     return $existingItem;
 }