コード例 #1
0
 /**
  * @return void
  */
 public function testPluginExpandsCartItemWithExpectedProductData()
 {
     $localeName = Store::getInstance()->getCurrentLocale();
     $localeTransfer = $this->localeFacade->getLocale($localeName);
     $taxRateEntity = new SpyTaxRate();
     $taxRateEntity->setRate(self::TAX_RATE_PERCENTAGE)->setName(self::TAX_RATE_NAME);
     $taxSetEntity = new SpyTaxSet();
     $taxSetEntity->addSpyTaxRate($taxRateEntity)->setName(self::TAX_SET_NAME);
     $productAbstractEntity = new SpyProductAbstract();
     $productAbstractEntity->setSpyTaxSet($taxSetEntity)->setAttributes('')->setSku(self::SKU_PRODUCT_ABSTRACT);
     $localizedAttributesEntity = new SpyProductLocalizedAttributes();
     $localizedAttributesEntity->setName(self::PRODUCT_CONCRETE_NAME)->setAttributes('')->setFkLocale($localeTransfer->getIdLocale());
     $productConcreteEntity = new SpyProduct();
     $productConcreteEntity->setSpyProductAbstract($productAbstractEntity)->setAttributes('')->addSpyProductLocalizedAttributes($localizedAttributesEntity)->setSku(self::SKU_PRODUCT_CONCRETE)->save();
     $changeTransfer = new CartChangeTransfer();
     $itemTransfer = new ItemTransfer();
     $itemTransfer->setSku(self::SKU_PRODUCT_CONCRETE);
     $changeTransfer->addItem($itemTransfer);
     $this->productCartConnectorFacade->expandItems($changeTransfer);
     $expandedItemTransfer = $changeTransfer->getItems()[0];
     $this->assertEquals(self::SKU_PRODUCT_ABSTRACT, $expandedItemTransfer->getAbstractSku());
     $this->assertEquals(self::SKU_PRODUCT_CONCRETE, $expandedItemTransfer->getSku());
     $this->assertEquals($productAbstractEntity->getIdProductAbstract(), $expandedItemTransfer->getIdProductAbstract());
     $this->assertEquals($productConcreteEntity->getIdProduct(), $expandedItemTransfer->getId());
 }
コード例 #2
0
 /**
  * @return void
  */
 public function testExpandItemMustNotChangeGroupKeyWhenGroupKeyIsSet()
 {
     $itemTransfer = new ItemTransfer();
     $itemTransfer->setSku(self::SKU);
     $itemTransfer->setGroupKey(self::SKU);
     $changeTransfer = new CartChangeTransfer();
     $changeTransfer->addItem($itemTransfer);
     $plugin = new SkuGroupKeyPlugin(new Factory('Cart'), Locator::getInstance());
     $plugin->expandItems($changeTransfer);
     $this->assertSame(self::SKU, $changeTransfer->getItems()[0]->getGroupKey());
 }
コード例 #3
0
 /**
  * @return \Generated\Shared\Transfer\CartChangeTransfer
  */
 protected function createCartChangeTransfer(array $cartItems)
 {
     $changeTransfer = new CartChangeTransfer();
     foreach ($cartItems as $cartItem => $options) {
         $cartItem = new ItemTransfer();
         foreach ($options as $option) {
             $cartItem->addProductOption($option);
         }
         $changeTransfer->addItem($cartItem);
     }
     return $changeTransfer;
 }
コード例 #4
0
 /**
  * @expectedException \Spryker\Zed\PriceCartConnector\Business\Exception\PriceMissingException
  * @expectedExceptionMessage Cart item 123 can not be priced
  *
  * @return void
  */
 public function testIsNotPriceAbleWithInvalidPrice()
 {
     $priceFacadeStub = $this->createPriceFacadeStub();
     $priceFacadeStub->addPriceStub('123', 1000);
     $priceFacadeStub->addValidityStub('123', false);
     $itemCollection = new CartChangeTransfer();
     $item = new ItemTransfer();
     $item->setId(123);
     $item->setSku(123);
     $itemCollection->addItem($item);
     $priceCartToPriceBridge = new PriceCartToPriceBridge($priceFacadeStub);
     $priceManager = new PriceManager($priceCartToPriceBridge, 'grossPrice');
     $priceManager->addGrossPriceToItems($itemCollection);
 }
コード例 #5
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());
 }
コード例 #6
0
 /**
  * @return \Generated\Shared\Transfer\CartChangeTransfer
  */
 private function getChangeTransfer()
 {
     $changeTransfer = new CartChangeTransfer();
     $itemTransfer = new ItemTransfer();
     $itemTransfer->setSku(self::CONCRETE_SKU);
     $changeTransfer->addItem($itemTransfer);
     return $changeTransfer;
 }
コード例 #7
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);
 }