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);
 }
 /**
  * @Route("/cart/{id}", name="orocrm_magento_orderplace_cart", requirements={"id"="\d+"}))
  * @AclAncestor("oro_workflow")
  * @Template("OroCRMMagentoBundle:OrderPlace:widget/place.html.twig")
  * @param Cart $cart
  * @return array
  */
 public function cartAction(Cart $cart)
 {
     $urlGenerator = $this->get('orocrm_magento.service.magento_url_generator')->setChannel($cart->getChannel())->setFlowName('oro_sales_new_order')->setOrigin('quote')->generate($cart->getOriginId(), 'orocrm_magento_orderplace_success', 'orocrm_magento_orderplace_error');
     $translator = $this->get('translator');
     return ['error' => $urlGenerator->isError() ? $translator->trans($urlGenerator->getError()) : false, 'sourceUrl' => $urlGenerator->getSourceUrl(), 'cartId' => $cart->getId()];
 }
Exemple #3
0
 /**
  * @Route("/actualize/{id}", name="orocrm_magento_cart_actualize", requirements={"id"="\d+"}))
  * @AclAncestor("orocrm_magento_cart_view")
  */
 public function actualizeAction(Cart $cart)
 {
     $connector = $this->get('orocrm_magento.mage.cart_connector');
     try {
         $processor = $this->get('oro_integration.sync.processor');
         $processor->process($cart->getChannel(), $connector->getType(), ['filters' => ['entity_id' => $cart->getOriginId()]]);
         $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_cart_view', ['id' => $cart->getId()]));
 }
Exemple #4
0
 /**
  * @return int
  */
 protected function getMainEntityId()
 {
     $this->assertNotEmpty(self::$cart);
     return self::$cart->getId();
 }