コード例 #1
0
ファイル: CartClient.php プロジェクト: spryker/Cart
 /**
  * @return \Generated\Shared\Transfer\CartChangeTransfer
  */
 protected function createCartChangeTransfer()
 {
     $quoteTransfer = $this->getSession()->getQuote();
     $items = $quoteTransfer->getItems();
     if (count($items) === 0) {
         $quoteTransfer->setItems(new \ArrayObject());
     }
     $cartChangeTransfer = new CartChangeTransfer();
     $cartChangeTransfer->setQuote($quoteTransfer);
     return $cartChangeTransfer;
 }
コード例 #2
0
ファイル: CartFacadeTest.php プロジェクト: spryker/Cart
 /**
  * @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
 /**
  * @expectedException \Spryker\Zed\Cart\Business\Exception\InvalidQuantityExeption
  * @expectedExceptionMessage Could not change cart item "123" with "0" as value.
  *
  * @return void
  */
 public function testDecreaseWithZeroValue()
 {
     $itemId = '123';
     $newId = '123';
     $existingQuantity = 1;
     $newQuantity = 0;
     $quoteTransfer = $this->createQuoteWithItem($itemId, $existingQuantity);
     $newItem = $this->createItem($newId, $newQuantity);
     $change = new CartChangeTransfer();
     $change->addItem($newItem);
     $change->setQuote($quoteTransfer);
     $this->provider->removeItems($change);
 }