public function testCustomerSyncAction() { $newCustomerOrder = $this->getModifiedCustomerOrder($this->customer); $orderIterator = new StubIterator([$newCustomerOrder]); $this->soapTransport->expects($this->any())->method('call'); /*$this->soapTransport->expects($this->once())->method('getCustomer')->will( $this->returnValue($customerIterator) );*/ $this->soapTransport->expects($this->once())->method('getOrders')->will($this->returnValue($orderIterator)); $this->client->request('GET', $this->getUrl('orocrm_magento_orderplace_new_customer_order_sync', ['id' => $this->customer->getId()]), [], [], ['HTTP_X-Requested-With' => 'XMLHttpRequest']); $result = $this->client->getResponse(); $this->assertJsonResponseStatusCodeEquals($result, 200); $arrayJson = json_decode($result->getContent(), 1); $this->assertEquals($arrayJson['statusType'], 'success'); $this->assertEquals($arrayJson['message'], 'Data successfully synchronized.'); $this->assertEquals($arrayJson['url'], $this->getUrl('orocrm_magento_order_view', ['id' => $this->order->getId()])); $this->client->request('GET', $this->getUrl('orocrm_magento_customer_view', ['id' => $this->customer->getId()])); $result = $this->client->getResponse(); $this->assertHtmlResponseStatusCodeEquals($result, 200); $this->assertContains('General Information', $result->getContent()); $this->assertContains('100000307', $result->getContent()); $this->assertContains('$750', $result->getContent()); $this->assertContains('pending', $result->getContent()); $this->assertContains('$755', $result->getContent()); $this->assertContains('$755', $result->getContent()); }
/** * @param Order|object $order * @param float|null $newLifetime * @param array $changeSet * @dataProvider updateDataProvider */ public function testUpdate($order, $newLifetime = null, array $changeSet = array()) { $isUpdateRequired = array_intersect(array('subtotalAmount', 'status'), array_keys($changeSet)); if ($isUpdateRequired && $newLifetime) { $entityManager = $this->createEntityManagerMock($order->getCustomer(), $newLifetime); } else { $entityManager = $this->createEntityManagerMock(); } $listener = new OrderListener(); $listener->preUpdate(new PreUpdateEventArgs($order, $entityManager, $changeSet)); if ($isUpdateRequired) { $this->assertAttributeEquals(array($order->getId() => true), 'ordersForUpdate', $listener); } else { $this->assertAttributeEmpty('ordersForUpdate', $listener); } $listener->postUpdate(new LifecycleEventArgs($order, $entityManager)); $this->assertAttributeEmpty('ordersForUpdate', $listener); }
/** * @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()])); }