Example #1
0
 /**
  * Test setting removed field on removed cart items
  */
 public function testUpdateRemovedCartItems()
 {
     $channel = new Channel();
     $cartItem1 = new CartItem();
     $cartItem1->setName('Cart Item 1');
     $cartItem2 = new CartItem();
     $cartItem2->setName('Cart Item 2');
     $cartItem3 = new CartItem();
     $cartItem3->setName('Cart Item 3');
     $existingCartItems = new ArrayCollection();
     $existingCartItems->add($cartItem1);
     $existingCartItems->add($cartItem2);
     $existingCart = new Cart();
     $existingCart->setCartItems($existingCartItems);
     $existingCart->setChannel($channel);
     $existingCart->setItemsQty(2);
     $newCartItems = new ArrayCollection();
     $newCartItems->add($cartItem2);
     $newCartItems->add($cartItem3);
     $newCart = new Cart();
     $newCart->setCartItems($newCartItems);
     $newCart->setChannel($channel);
     $newCart->setItemsQty(2);
     $this->databaseHelper->expects($this->once())->method('findOneByIdentity')->will($this->returnValue($existingCart));
     $this->databaseHelper->expects($this->once())->method('getEntityReference')->will($this->returnValue($channel));
     $this->databaseHelper->expects($this->once())->method('getIdentifier')->will($this->returnValue('identifier'));
     $this->databaseHelper->expects($this->once())->method('find')->with('OroCRM\\Bundle\\MagentoBundle\\Entity\\Cart', 'identifier')->will($this->returnValue($newCart));
     $strategy = $this->getStrategy();
     /** @var \PHPUnit_Framework_MockObject_MockObject|ContextInterface $context */
     $context = $this->getMock('Oro\\Bundle\\ImportExportBundle\\Context\\ContextInterface');
     $strategy->setImportExportContext($context);
     $strategy->setEntityName('OroCRM\\Bundle\\MagentoBundle\\Entity\\Cart');
     $execution = $this->getMock('Akeneo\\Bundle\\BatchBundle\\Item\\ExecutionContext');
     $this->jobExecution->expects($this->any())->method('getExecutionContext')->will($this->returnValue($execution));
     $strategy->setStepExecution($this->stepExecution);
     $strategy->process($existingCart);
     $this->assertTrue($cartItem1->isRemoved());
     $this->assertFalse($cartItem2->isRemoved());
     $this->assertFalse($cartItem3->isRemoved());
 }
Example #2
0
 /**
  * @param                 $billing
  * @param                 $shipping
  * @param Customer        $customer
  * @param ArrayCollection $item
  * @param CartStatus      $status
  *
  * @return Cart
  */
 protected function createCart($billing, $shipping, Customer $customer, ArrayCollection $item, $status)
 {
     $cart = new Cart();
     $cart->setChannel($this->integration);
     $cart->setDataChannel($this->channel);
     $cart->setBillingAddress($billing);
     $cart->setShippingAddress($shipping);
     $cart->setCustomer($customer);
     $cart->setEmail('*****@*****.**');
     $cart->setCreatedAt(new \DateTime('now'));
     $cart->setUpdatedAt(new \DateTime('now'));
     $cart->setCartItems($item);
     $cart->setStatus($status);
     $cart->setItemsQty(0);
     $cart->setItemsCount(1);
     $cart->setBaseCurrencyCode('code');
     $cart->setStoreCurrencyCode('code');
     $cart->setQuoteCurrencyCode('usd');
     $cart->setStoreToBaseRate(12);
     $cart->setGrandTotal(2.54);
     $cart->setIsGuest(0);
     $cart->setStore($this->store);
     $cart->setOwner($this->getUser());
     $cart->setOrganization($this->organization);
     $this->em->persist($cart);
     return $cart;
 }