Exemple #1
0
 /**
  * Assign existing customer, if not found - set null
  *
  * @param Cart     $newCart
  * @param Customer $customer
  *
  * @return CartStrategy
  */
 protected function updateCustomer(Cart $newCart, Customer $customer)
 {
     $existingCustomer = $this->getEntityByCriteria(['originId' => $customer->getOriginId(), 'channel' => $customer->getChannel()], $customer);
     if ($existingCustomer) {
         $newCart->setCustomer($existingCustomer);
     } else {
         $newCart->setCustomer(null);
     }
     return $this;
 }
 public function testProcess()
 {
     $customer = new Customer();
     $customer->setOriginId(1);
     $channel = new Channel();
     $cart = new Cart();
     $cart->setCustomer($customer)->setChannel($channel)->setItemsCount(2)->setEmail('*****@*****.**');
     $strategy = $this->getStrategy();
     $execution = $this->getMock('Akeneo\\Bundle\\BatchBundle\\Item\\ExecutionContext');
     $this->jobExecution->expects($this->any())->method('getExecutionContext')->will($this->returnValue($execution));
     $strategy->setStepExecution($this->stepExecution);
     $cartItem = ['customerId' => uniqid()];
     /** @var \PHPUnit_Framework_MockObject_MockObject|ContextInterface $context */
     $context = $this->getMock('Oro\\Bundle\\ImportExportBundle\\Context\\ContextInterface');
     $context->expects($this->once())->method('getValue')->will($this->returnValue($cartItem));
     $strategy->setImportExportContext($context);
     $execution->expects($this->exactly(2))->method('get')->with($this->isType('string'));
     $execution->expects($this->exactly(2))->method('put')->with($this->isType('string'), $this->isType('array'));
     $this->assertNull($strategy->process($cart));
 }
Exemple #3
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;
 }
Exemple #4
0
 /**
  * @param ObjectManager $om
  * @param Store         $store
  * @param Integration   $integration
  * @param Customer      $customer
  * @param CartStatus    $status
  * @param int           $origin
  * @param string        $currency
  * @param int           $rate
  *
  * @return Cart
  */
 protected function generateShoppingCart(ObjectManager $om, Store $store, Integration $integration, Customer $customer, CartStatus $status, $origin, $currency = 'USD', $rate = 1)
 {
     $cart = new Cart();
     $cart->setOrganization($this->organization);
     $cart->setChannel($integration);
     $cart->setCustomer($customer);
     $cart->setOwner($customer->getOwner());
     $cart->setStatus($status);
     $cart->setStore($store);
     $cart->setBaseCurrencyCode($currency);
     $cart->setStoreCurrencyCode($currency);
     $cart->setQuoteCurrencyCode($currency);
     $cart->setStoreToBaseRate($rate);
     $cart->setStoreToQuoteRate($rate);
     $cart->setIsGuest(0);
     $cart->setEmail($customer->getEmail());
     $cart->setCreatedAt(new \DateTime('now'));
     $cart->setUpdatedAt(new \DateTime('now'));
     $cart->setOriginId($origin);
     $cart->setDataChannel($this->dataChannel);
     $om->persist($cart);
     return $cart;
 }