public function testSyncAction() { $jobManager = $this->getContainer()->get('akeneo_batch.job_repository')->getJobManager(); $jobManager->beginTransaction(); $newCart = $this->getModifiedCartData($this->cart, $this->customer); $cartIterator = new StubIterator([$newCart]); $orderIterator = new StubIterator([['increment_id' => $this->order->getIncrementId(), 'quote_id' => $this->cart->getOriginId()]]); $customerIterator = new StubIterator([]); $this->soapTransport->expects($this->any())->method('call'); $this->soapTransport->expects($this->once())->method('getCarts')->will($this->returnValue($cartIterator)); $this->soapTransport->expects($this->once())->method('getOrders')->will($this->returnValue($orderIterator)); $this->soapTransport->expects($this->any())->method('getCustomers')->will($this->returnValue($customerIterator)); $this->client->request('GET', $this->getUrl('orocrm_magento_orderplace_new_cart_order_sync', ['id' => $this->cart->getId()]), [], [], ['HTTP_X-Requested-With' => 'XMLHttpRequest']); $result = $this->client->getResponse(); $this->assertJsonResponseStatusCodeEquals($result, 200); $arrayJson = json_decode($result->getContent(), 1); $this->assertEquals('success', $arrayJson['statusType']); $this->assertEquals('Data successfully synchronized.', $arrayJson['message']); $this->assertEquals($arrayJson['url'], $this->getUrl('orocrm_magento_order_view', ['id' => $this->order->getId()])); $jobManager->rollback(); $this->client->request('GET', $this->getUrl('orocrm_magento_cart_view', ['id' => $this->cart->getId()])); $result = $this->client->getResponse(); $this->assertHtmlResponseStatusCodeEquals($result, 200); $resultContent = $result->getContent(); $this->assertContains('Cart Information', $resultContent); $this->assertContains(self::TEST_NEW_EMAIL, $resultContent); $this->assertContains((string) self::TEST_NEW_ITEMS_QTY, $resultContent); $this->assertContains('Expired', $resultContent); $this->assertContains('Customer Information', $resultContent); $this->assertContains('*****@*****.**', $resultContent); }
/** * @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]]]; }
/** * @Route("/actualize/{id}", name="orocrm_magento_order_actualize", requirements={"id"="\d+"})) * @AclAncestor("orocrm_magento_order_view") * @param Order $order * @return \Symfony\Component\HttpFoundation\RedirectResponse */ public function actualizeAction(Order $order) { $result = false; try { $result = $this->loadOrderInformation($order->getChannel(), ['filters' => ['increment_id' => $order->getIncrementId()]]); } catch (\LogicException $e) { $this->get('logger')->addCritical($e->getMessage(), ['exception' => $e]); } if ($result === true) { $this->get('session')->getFlashBag()->add('success', $this->get('translator')->trans('orocrm.magento.controller.synchronization_success')); } else { $this->get('session')->getFlashBag()->add('error', $this->get('translator')->trans('orocrm.magento.controller.synchronization_error')); } return $this->redirect($this->generateUrl('orocrm_magento_order_view', ['id' => $order->getId()])); }
/** * @Route("/actualize/{id}", name="orocrm_magento_order_actualize", requirements={"id"="\d+"})) * @AclAncestor("orocrm_magento_order_view") */ public function actualizeAction(Order $order) { try { $processor = $this->get('oro_integration.sync.processor'); $processor->process($order->getChannel(), 'order', ['filters' => ['increment_id' => $order->getIncrementId()]]); $this->get('session')->getFlashBag()->add('success', $this->get('translator')->trans('orocrm.magento.controller.synchronization_success')); } catch (\LogicException $e) { $this->get('logger')->addCritical($e->getMessage(), ['exception' => $e]); $this->get('session')->getFlashBag()->add('error', $this->get('translator')->trans('orocrm.magento.controller.synchronization_error')); } return $this->redirect($this->generateUrl('orocrm_magento_order_view', ['id' => $order->getId()])); }