/**
  * Test dimensions transformation.
  *
  * @group Order
  */
 public function testCreateOrderFromCartDimensions()
 {
     /**
      * @var OrderInterface    $order
      * @var CurrencyInterface $currency
      */
     $order = $this->getMock('Elcodi\\Component\\Cart\\Entity\\Order', null);
     $currency = $this->getMock('Elcodi\\Component\\Currency\\Entity\\Currency', null);
     $currency->setIso('EUR');
     $this->orderFactory->expects($this->once())->method('create')->will($this->returnValue($order));
     $this->cartLineOrderLineTransformer->expects($this->any())->method('createOrderLinesByCartLines')->will($this->returnValue(new ArrayCollection()));
     $cart = $this->getMock('Elcodi\\Component\\Cart\\Entity\\Cart');
     $cart->expects($this->any())->method('getCartLines')->will($this->returnValue(new ArrayCollection()));
     $cart->expects($this->any())->method('getShippingAmount')->will($this->returnValue($this->getMock('Elcodi\\Component\\Currency\\Entity\\Interfaces\\MoneyInterface')));
     $cart->expects($this->any())->method('getCustomer')->will($this->returnValue(new Customer()));
     $cart->expects($this->any())->method('getPurchasableAmount')->will($this->returnValue(Money::create(10, $currency)));
     $cart->expects($this->any())->method('getCouponAmount')->will($this->returnValue(Money::create(0, $currency)));
     $cart->expects($this->any())->method('getAmount')->will($this->returnValue(Money::create(10, $currency)));
     $cart->expects($this->any())->method('getWeight')->will($this->returnValue(10));
     $cart->expects($this->any())->method('getHeight')->will($this->returnValue(11));
     $cart->expects($this->any())->method('getWidth')->will($this->returnValue(12));
     $cart->expects($this->any())->method('getDepth')->will($this->returnValue(13));
     $order = $this->cartOrderTransformer->createOrderFromCart($cart);
     $this->assertEquals(10, $order->getWeight());
     $this->assertEquals(11, $order->getHeight());
     $this->assertEquals(12, $order->getWidth());
     $this->assertEquals(13, $order->getDepth());
 }
 /**
  * test Create Order from Cart
  *
  * @group order
  */
 public function testCreateOrderFromCartNewOrderExistingOrder()
 {
     /**
      * @var OrderInterface    $order
      * @var CurrencyInterface $currency
      */
     $order = $this->getMock('Elcodi\\Component\\Cart\\Entity\\Order', null);
     $currency = $this->getMock('Elcodi\\Component\\Currency\\Entity\\Currency', null);
     $currency->setIso('EUR');
     $this->orderFactory->expects($this->never())->method('create')->will($this->returnValue($order));
     $this->cartLineOrderLineTransformer->expects($this->any())->method('createOrderLinesByCartLines')->will($this->returnValue(new ArrayCollection()));
     $customer = new Customer();
     $cart = new Cart();
     $cart->setCustomer($customer)->setQuantity(10)->setProductAmount(Money::create(20, $currency))->setOrder($order)->setAmount(Money::create(20, $currency))->setCartLines(new ArrayCollection());
     $this->cartOrderTransformer->createOrderFromCart($cart);
 }
 /**
  * Create order given current cart. This event is only for pushing the new
  * Order to the payment infrastructure
  *
  * @param AbstractPaymentEvent $event Event
  */
 public function transformCartToOrder(AbstractPaymentEvent $event)
 {
     $cart = $this->cartWrapper->get();
     $order = $this->cartOrderTransformer->createOrderFromCart($cart);
     $event->getPaymentBridge()->setOrder($order);
 }