Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 protected function getConnectors(array $entities)
 {
     $dictionaryConnectors = $this->typeRegistry->getRegisteredConnectorsTypes(ChannelType::TYPE, function (ConnectorInterface $connector) {
         return $connector instanceof DictionaryConnectorInterface;
     })->toArray();
     $connectors = [];
     $initialConnectors = [];
     $isSupportedExtensionVersion = $this->transportEntity->isSupportedExtensionVersion();
     $isExtensionInstalled = $this->transportEntity->getIsExtensionInstalled();
     foreach ($entities as $entity) {
         $connectorName = $this->settingsProvider->getIntegrationConnectorName($entity);
         if ($connectorName) {
             $connector = $this->typeRegistry->getConnectorType(ChannelType::TYPE, $connectorName);
             if (!$connector) {
                 continue;
             }
             $isExtensionApplicable = $connector instanceof ExtensionVersionAwareInterface ? $isSupportedExtensionVersion : $isExtensionInstalled;
             if ($isExtensionApplicable || !$isExtensionApplicable && !$connector instanceof ExtensionAwareInterface) {
                 array_push($initialConnectors, $connectorName . InitialSyncProcessor::INITIAL_CONNECTOR_SUFFIX);
                 array_push($connectors, $connectorName);
             }
         }
     }
     return array_merge(array_keys($dictionaryConnectors), $initialConnectors, $connectors);
 }
Ejemplo n.º 2
0
 public function testWsdlUrl()
 {
     $url = 'http://test.local/?wsdl=1';
     $cache = '/tmp/cached.wsdl';
     $this->entity->setWsdlUrl($url);
     $this->assertEquals($url, $this->entity->getSettingsBag()->get('wsdl_url'));
     $this->entity->setWsdlCachePath($cache);
     $this->assertEquals($cache, $this->entity->getSettingsBag()->get('wsdl_url'));
 }
Ejemplo n.º 3
0
 public function testSettingsBag()
 {
     $data = array('api_user' => 'test_user', 'api_key' => 'test_key', 'wsdl_url' => 'http://test.url/', 'sync_range' => new \DateInterval('P1D'), 'wsi_mode' => true, 'website_id' => 1, 'start_sync_date' => new \DateTime('now'));
     $this->entity->setApiUser($data['api_user'])->setApiKey($data['api_key'])->setWsdlUrl($data['wsdl_url'])->setSyncRange($data['sync_range'])->setIsWsiMode($data['wsi_mode'])->setWebsiteId($data['website_id'])->setSyncStartDate($data['start_sync_date']);
     $settingsBag = $this->entity->getSettingsBag();
     $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\ParameterBag', $settingsBag);
     $this->assertSame($settingsBag, $this->entity->getSettingsBag());
     $this->assertEquals($data, $settingsBag->all());
 }
 public function testProcess()
 {
     $connectors = ['testConnector_initial'];
     $syncStartDate = new \DateTime('now', new \DateTimeZone('UTC'));
     $realConnector = new InitialConnector();
     $integration = $this->getIntegration($connectors, $syncStartDate, $realConnector);
     $transport = new MagentoSoapTransport();
     $transport->setNewsletterSubscriberSyncedToId(42);
     $integration->expects($this->any())->method('getTransport')->will($this->returnValue($transport));
     $this->assertProcessCalls();
     $this->assertExecuteJob(['initialSyncInterval' => '7 days', 'processorAlias' => false, 'entityName' => 'testEntity', 'channel' => 'testChannel', 'channelType' => 'testChannelType', 'initial_id' => 42]);
     $this->processor->process($integration);
 }
Ejemplo n.º 5
0
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $om)
 {
     $this->organization = $this->getReference('default_organization');
     $this->users = $om->getRepository('OroUserBundle:User')->findAll();
     $website = new Website();
     $website->setCode('admin')->setName('Admin');
     $om->persist($website);
     $store = new Store();
     $store->setCode('admin')->setName('Admin')->setWebsite($website);
     $om->persist($website);
     $group = new CustomerGroup();
     $group->setName('General');
     $om->persist($group);
     $transport = new MagentoSoapTransport();
     $transport->setApiUser('api_user');
     $transport->setApiKey('api_key');
     $transport->setWsdlUrl('http://magento.domain');
     $om->persist($transport);
     $integration = new Integration();
     $integration->setType('magento');
     $integration->setConnectors(['customer', 'cart', 'order']);
     $integration->setName(self::INTEGRATION_NAME);
     $integration->setTransport($transport);
     $integration->setOrganization($this->organization);
     $om->persist($integration);
     $builder = $this->factory->createBuilderForIntegration($integration);
     $builder->setOwner($integration->getOrganization());
     $builder->setDataSource($integration);
     $builder->setStatus($integration->getEnabled() ? Channel::STATUS_ACTIVE : Channel::STATUS_INACTIVE);
     $this->dataChannel = $builder->getChannel();
     $om->persist($this->dataChannel);
     $om->flush();
     $this->persistDemoCustomers($om, $website, $store, $group, $integration);
     $om->flush();
     $this->persistDemoCarts($om, $store, $integration);
     $om->flush();
     $this->persistDemoOrders($om, $store, $integration);
     $om->flush();
 }
Ejemplo n.º 6
0
 /**
  * @return $this
  */
 protected function createTransport()
 {
     $transport = new MagentoSoapTransport();
     $transport->setAdminUrl('http://localhost/magento/admin');
     $transport->setApiKey('key');
     $transport->setApiUser('user');
     $transport->setIsExtensionInstalled(true);
     $transport->setIsWsiMode(false);
     $transport->setWebsiteId('1');
     $transport->setWsdlUrl('http://localhost/magento/api/v2_soap?wsdl=1');
     $transport->setWebsites([['id' => 1, 'label' => 'Website ID: 1, Stores: English, French, German']]);
     $this->em->persist($transport);
     $this->transport = $transport;
     return $this;
 }
Ejemplo n.º 7
0
 /**
  * @param array $connectors
  * @param \DateTime $syncStartDate
  * @param object|null $realConnector
  * @return Channel|\PHPUnit_Framework_MockObject_MockObject
  */
 protected function getIntegration(array $connectors = [], \DateTime $syncStartDate = null, $realConnector = null)
 {
     $integration = $this->getMockBuilder('Oro\\Bundle\\IntegrationBundle\\Entity\\Channel')->disableOriginalConstructor()->getMock();
     $integration->expects($this->any())->method('getConnectors')->will($this->returnValue($connectors));
     $integration->expects($this->any())->method('getId')->will($this->returnValue('testChannel'));
     $integration->expects($this->any())->method('getType')->will($this->returnValue('testChannelType'));
     $transport = new MagentoSoapTransport();
     if ($syncStartDate) {
         $transport->setSyncStartDate($syncStartDate);
     }
     $integration->expects($this->any())->method('getTransport')->will($this->returnValue($transport));
     $integration->expects($this->any())->method('isEnabled')->will($this->returnValue(true));
     if (!$realConnector) {
         $realConnector = new TestConnector();
     }
     $this->typesRegistry->expects($this->any())->method('getConnectorType')->will($this->returnValue($realConnector));
     return $integration;
 }
 public function testOnChannelSucceedSave()
 {
     $this->entity->setChannelType(ChannelType::TYPE);
     $transport = new MagentoSoapTransport();
     $transport->setIsExtensionInstalled(false);
     $this->integration->setTransport($transport);
     $this->typesRegistry->expects($this->any())->method('getRegisteredConnectorsTypes')->willReturn(new ArrayCollection([]));
     $this->prepareEvent();
     $this->getListener()->onChannelSucceedSave($this->event);
 }