public function testCreate() { $pricing = $this->dummyData->getPricing(); $cart = $this->dummyData->getCart(); $cartItemOptionProduct = $this->dummyData->getCartItemOptionProduct(); $cartItemOptionValue = $this->dummyData->getCartItemOptionValue(); $cartItemTextOptionValue = $this->dummyData->getCartItemTextOptionValue(); $product = $this->dummyData->getProduct(); $product->setShippingWeight(1); $product->setSku('P1'); $cartItemOptionProduct->getOptionProduct()->getProduct()->setSku('OP1'); $cartItemOptionProduct->getOptionProduct()->getProduct()->setShippingWeight(3); $cartItemOptionValue->getOptionValue()->setSku('OV1'); $cartItemOptionValue->getOptionValue()->setShippingWeight(5); $cartItem = new CartItem(); $cartItem->setProduct($product); $cartItem->setQuantity(2); $cartItem->setCart($cart); $cartItem->addCartItemOptionProduct($cartItemOptionProduct); $cartItem->addCartItemOptionValue($cartItemOptionValue); $cartItem->addCartItemTextOptionValue($cartItemTextOptionValue); $this->assertEntityValid($cartItem); $this->assertTrue($cartItem instanceof CartItem); $this->assertTrue($cartItem->getPrice($pricing) instanceof Price); $this->assertSame(2, $cartItem->getQuantity()); $this->assertSame('P1-OP1-OV1', $cartItem->getFullSku()); $this->assertSame(18, $cartItem->getShippingWeight()); $this->assertSame($cart, $cartItem->getCart()); $this->assertSame($cartItemOptionProduct, $cartItem->getCartItemOptionProducts()[0]); $this->assertSame($cartItemOptionValue, $cartItem->getCartItemOptionValues()[0]); $this->assertSame($cartItemTextOptionValue, $cartItem->getCartItemTextOptionValues()[0]); }
public function getCartItemFull() { $tag = $this->getTag(); $tag->addImage($this->getImage()); $product = $this->getProduct(); $product->setSku('P1'); $product->setUnitPrice(100); $product->setShippingWeight(10); $product->addTag($tag); $product->addProductQuantityDiscount($this->getProductQuantityDiscount()); $product2 = $this->getProduct(); $product2->setSku('OP1'); $product2->setUnitPrice(100); $product2->setShippingWeight(10); $option1 = $this->getOption(); $option1->setName('Option 1'); $optionProduct = $this->getOptionProduct($option1, $product2); $option2 = $this->getOption(); $option2->setName('Option 2'); $optionValue = $this->getOptionValue($option2); $optionValue->setSku('OV1'); $optionValue->setUnitPrice(100); $optionValue->setShippingWeight(10); $textOption = $this->getTextOption(); $cartItemOptionProduct = $this->getCartItemOptionProduct($optionProduct); $cartItemOptionValue = new CartItemOptionValue(); $cartItemOptionValue->setOptionValue($optionValue); $cartItemTextOptionValue = new CartItemTextOptionValue(); $cartItemTextOptionValue->setTextOption($textOption); $cartItemTextOptionValue->setTextOptionValue('Happy Birthday'); $cartItem = new CartItem(); $cartItem->setProduct($product); $cartItem->setQuantity(2); $cartItem->setCart(new Cart()); $cartItem->addCartItemOptionProduct($cartItemOptionProduct); $cartItem->addCartItemOptionValue($cartItemOptionValue); $cartItem->addCartItemTextOptionValue($cartItemTextOptionValue); return $cartItem; }