/**
  * @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());
 }
Example #2
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;
 }
Example #3
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());
 }
 /**
  * @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);
 }
 /**
  * @return \Generated\Shared\Transfer\QuoteTransfer
  */
 private function getCheckoutRequestTransfer()
 {
     $itemTransfer = new ItemTransfer();
     $itemTransfer->setSku('1234567890')->setQuantity(1)->setUnitGrossPriceWithProductOptions(10000)->setName('Socken');
     $billingAddressTransfer = new AddressTransfer();
     $billingAddressTransfer->setIso2Code('DE')->setEmail('*****@*****.**')->setFirstName('John')->setLastName('Doe')->setAddress1('Straße des 17. Juni')->setAddress2('135')->setZipCode('10623')->setCity('Berlin');
     $shippingAddressTransfer = new AddressTransfer();
     $shippingAddressTransfer->setIso2Code('DE')->setEmail('*****@*****.**')->setFirstName('John')->setLastName('Doe')->setAddress1('Fraunhoferstraße')->setAddress2('120')->setZipCode('80469')->setCity('München');
     $paymentAddressTransfer = (new AddressTransfer())->setFirstName('John')->setLastName('Doe')->setSalutation('Mr')->setEmail('*****@*****.**')->setCity('Berlin')->setIso2Code('DE')->setAddress1('Straße des 17. Juni')->setAddress2('135')->setZipCode('10623');
     $payolutionPaymentTransfer = (new PayolutionPaymentTransfer())->setGender('Male')->setDateOfBirth('1970-01-01')->setClientIp('127.0.0.1')->setAccountBrand(PayolutionConstants::BRAND_INVOICE)->setAddress($paymentAddressTransfer);
     $quoteTransfer = new QuoteTransfer();
     $totalsTransfer = new TotalsTransfer();
     $totalsTransfer->setGrandTotal(10000)->setSubtotal(10000);
     $quoteTransfer->setTotals($totalsTransfer);
     $paymentTransfer = new PaymentTransfer();
     $paymentTransfer->setPaymentSelection('no_payment');
     $paymentTransfer->setPayolution($payolutionPaymentTransfer);
     $quoteTransfer->setPayment($paymentTransfer);
     $quoteTransfer->setShippingAddress($shippingAddressTransfer)->setBillingAddress($billingAddressTransfer);
     return $quoteTransfer;
 }
Example #6
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());
 }
Example #7
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);
 }
Example #8
0
 /**
  * @return \Generated\Shared\Transfer\QuoteTransfer
  */
 protected function getBaseQuoteTransfer()
 {
     $quoteTransfer = new QuoteTransfer();
     $country = new SpyCountry();
     $country->setIso2Code('xi')->save();
     $productAbstract1 = new SpyProductAbstract();
     $productAbstract1->setSku('AOSB1337')->setAttributes('{}');
     $productConcrete1 = new SpyProduct();
     $productConcrete1->setSku('OSB1337')->setAttributes('{}')->setSpyProductAbstract($productAbstract1)->save();
     $productAbstract2 = new SpyProductAbstract();
     $productAbstract2->setSku('AOSB1338')->setAttributes('{}');
     $productConcrete2 = new SpyProduct();
     $productConcrete2->setSku('OSB1338')->setSpyProductAbstract($productAbstract2)->setAttributes('{}')->save();
     $stock = new SpyStock();
     $stock->setName('testStock');
     $stock1 = new SpyStockProduct();
     $stock1->setQuantity(1)->setStock($stock)->setSpyProduct($productConcrete1)->save();
     $stock2 = new SpyStockProduct();
     $stock2->setQuantity(1)->setStock($stock)->setSpyProduct($productConcrete2)->save();
     $item1 = new ItemTransfer();
     $item1->setSku('OSB1337')->setQuantity(1)->setUnitGrossPrice(3000)->setName('Product1');
     $item2 = new ItemTransfer();
     $item2->setSku('OSB1338')->setQuantity(1)->setUnitGrossPrice(4000)->setName('Product2');
     $quoteTransfer->addItem($item1);
     $quoteTransfer->addItem($item2);
     $totals = new TotalsTransfer();
     $totals->setGrandTotal(1000)->setSubtotal(500);
     $quoteTransfer->setTotals($totals);
     $billingAddress = new AddressTransfer();
     $shippingAddress = new AddressTransfer();
     $billingAddress->setIso2Code('xi')->setEmail('*****@*****.**')->setFirstName('Max')->setLastName('Mustermann')->setAddress1('Straße')->setAddress2('82')->setZipCode('12345')->setCity('Entenhausen');
     $shippingAddress->setIso2Code('xi')->setFirstName('Max')->setLastName('Mustermann')->setEmail('*****@*****.**')->setAddress1('Straße')->setAddress2('84')->setZipCode('12346')->setCity('Entenhausen2');
     $quoteTransfer->setBillingAddress($billingAddress);
     $quoteTransfer->setShippingAddress($shippingAddress);
     $customerTransfer = new CustomerTransfer();
     $customerTransfer->setIsGuest(false)->setEmail('*****@*****.**');
     $quoteTransfer->setCustomer($customerTransfer);
     $shipment = new ShipmentTransfer();
     $shipment->setMethod(new ShipmentMethodTransfer());
     $quoteTransfer->setShipment($shipment);
     $paymentTransfer = new PaymentTransfer();
     $paymentTransfer->setPaymentSelection('no_payment');
     $quoteTransfer->setPayment($paymentTransfer);
     return $quoteTransfer;
 }
Example #9
0
 /**
  * @return \Generated\Shared\Transfer\QuoteTransfer
  */
 protected function getQuoteTransferWithTwoItems()
 {
     $quoteTransfer = new QuoteTransfer();
     $itemTransfer = new ItemTransfer();
     $itemTransfer->setUnitGrossPrice(self::ITEM_GROSS_PRICE_500);
     $itemTransfer->setSku('sku1');
     $quoteTransfer->addItem($itemTransfer);
     $quoteTransfer->addItem(clone $itemTransfer);
     return $quoteTransfer;
 }
 /**
  * @return \Generated\Shared\Transfer\CartChangeTransfer
  */
 private function getChangeTransfer()
 {
     $changeTransfer = new CartChangeTransfer();
     $itemTransfer = new ItemTransfer();
     $itemTransfer->setSku(self::CONCRETE_SKU);
     $changeTransfer->addItem($itemTransfer);
     return $changeTransfer;
 }
 /**
  * @return \Generated\Shared\Transfer\QuoteTransfer
  */
 protected function createQuoteTransfer()
 {
     $quoteTransfer = new QuoteTransfer();
     $itemTransfer = new ItemTransfer();
     $itemTransfer->setAbstractSku('123');
     $itemTransfer->setSku('123');
     $itemTransfer->setUnitGrossPrice(15000);
     $quoteTransfer->addItem($itemTransfer);
     $itemTransfer = new ItemTransfer();
     $itemTransfer->setAbstractSku('321');
     $itemTransfer->setSku('431');
     $itemTransfer->setUnitGrossPrice(1000);
     $quoteTransfer->addItem($itemTransfer);
     return $quoteTransfer;
 }
 /**
  * @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;
 }