public function testProcess() { $customer = new Customer(); $customer->setOriginId(1); $transport = $this->getMockBuilder('OroCRM\\Bundle\\MagentoBundle\\Entity\\MagentoSoapTransport')->disableOriginalConstructor()->getMock(); $transport->expects($this->once())->method('getIsExtensionInstalled')->will($this->returnValue(true)); $channel = $this->getMockBuilder('Oro\\Bundle\\IntegrationBundle\\Entity\\Channel')->disableOriginalConstructor()->getMock(); $channel->expects($this->once())->method('getTransport')->will($this->returnValue($transport)); $order = new Order(); $cart = new Cart(); $cart->setOriginId(1); $order->setCustomer($customer); $order->setChannel($channel); $order->setCart($cart); $this->databaseHelper->expects($this->once())->method('findOneByIdentity')->with($channel)->will($this->returnValue($channel)); $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); $orderItemDate = ['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($orderItemDate)); $strategy->setImportExportContext($context); $execution->expects($this->exactly(3))->method('get')->with($this->isType('string')); $execution->expects($this->exactly(3))->method('put')->with($this->isType('string'), $this->isType('array')); $this->assertNull($strategy->process($order)); }
/** * @return array */ public function itemsProvider() { $order1 = new Order(); $order2 = new Order(); $order1->setIncrementId('1111'); $order2->setIncrementId('2222'); $order3 = clone $order1; $cart1 = new Cart(); $cart2 = new Cart(); $cart1->setOriginId(1111); $cart2->setOriginId(2222); $cart3 = clone $cart1; $customer1 = new Customer(); $customer1->setOriginId(111); $customer2 = clone $customer1; $someEntity = new \stdClass(); $someEntity2 = new \stdClass(); return ['should skip non-unique orders' => ['$items' => [$order1, $order2, $order3], '$expectedItems' => [$order3->getIncrementId() => $order3, $order2->getIncrementId() => $order2]], 'should skip non-unique carts' => ['$items' => [$cart1, $cart2, $cart3], '$expectedItems' => [$cart3->getOriginId() => $cart3, $cart2->getOriginId() => $cart2]], 'should skip non-unique customers' => ['$items' => [$customer1, $customer2], '$expectedItems' => [$customer2->getOriginId() => $customer2]], 'should not break logic with entities that not consist originId' => ['$items' => [$someEntity, $someEntity2], '$expectedItems' => [$someEntity, $someEntity2]]]; }
/** * @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->setOriginId(100); $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->setStoreToQuoteRate(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; }
/** * @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; }