protected function setUp() { $this->em = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock(); $this->connection = $this->getMockBuilder('Doctrine\\DBAL\\Connection')->disableOriginalConstructor()->getMock(); $this->em->expects($this->any())->method('getConnection')->will($this->returnValue($this->connection)); $this->connection->expects($this->any())->method('beginTransaction'); $this->deleteManager = new DeleteManager($this->em); $this->deleteManager->addProvider(new TestIntegrationDeleteProvider()); $this->testIntegration = new Integration(); $this->testIntegration->setType('test'); }
public function testSchedule() { $testIntegrationType = 'testIntegrationType'; $testConnectorType = 'testConnectorType'; $testId = 22; $integration = new Integration(); $integration->setType($testIntegrationType); $integration->setEnabled(true); $ref = new \ReflectionProperty(get_class($integration), 'id'); $ref->setAccessible(true); $ref->setValue($integration, $testId); $this->typesRegistry->addChannelType($testIntegrationType, new TestIntegrationType()); $this->typesRegistry->addConnectorType($testConnectorType, $testIntegrationType, new TestTwoWayConnector()); $that = $this; $uow = $this->getMockBuilder('Doctrine\\ORM\\UnitOfWork')->disableOriginalConstructor()->getMock(); $this->em->expects($this->once())->method('getUnitOfWork')->will($this->returnValue($uow)); $metadataFactory = $this->getMockBuilder('Doctrine\\ORM\\Mapping\\ClassMetadataFactory')->disableOriginalConstructor()->getMock(); $metadataFactory->expects($this->once())->method('getMetadataFor')->will($this->returnValue(new ClassMetadata('testEntity'))); $this->em->expects($this->once())->method('getMetadataFactory')->will($this->returnValue($metadataFactory)); $uow->expects($this->once())->method('persist')->with($this->isInstanceOf('JMS\\JobQueueBundle\\Entity\\Job'))->will($this->returnCallback(function (Job $job) use($that, $testId, $testConnectorType) { $expectedArgs = ['--integration=' . $testId, sprintf('--connector=testConnectorType', $testConnectorType), '--params=a:0:{}']; $that->assertEquals($expectedArgs, $job->getArgs()); })); $uow->expects($this->once())->method('computeChangeSet'); $this->scheduler->schedule($integration, $testConnectorType, [], false); }
public function transformDataProvider() { $integration = new Integration(); $integration->setType(self::TEST_TYPE); $integration->setName(self::TEST_NAME); return ['should return null if empty data given' => ['$data' => null, '$expectedResult' => null], 'should return null if bad data given' => ['$data' => ['testBadData'], '$expectedResult' => null], 'should convert to expected array' => ['$data' => $integration, '$expectedResult' => ['type' => self::TEST_TYPE, 'data' => null, 'identifier' => $integration, 'name' => self::TEST_NAME]]]; }
/** * @Route("/create/{type}/{channelName}", requirements={"type"="\w+"}, name="orocrm_channel_integration_create") * @AclAncestor("oro_integration_create") * @Template("OroCRMChannelBundle:ChannelIntegration:update.html.twig") */ public function createAction($type, $channelName = null) { $translator = $this->get('translator'); $integrationName = urldecode($channelName) . ' ' . $translator->trans('orocrm.channel.data_source.label'); $integration = new Integration(); $integration->setType(urldecode($type)); $integration->setName(trim($integrationName)); return $this->update($integration); }
/** * @expectedException \LogicException * @expectedExceptionMessage Unable to schedule job for "testConnectorType" connector type */ public function testScheduleConnectorError() { $testIntegrationType = 'testIntegrationType'; $testConnectorType = 'testConnectorType'; $integration = new Integration(); $integration->setType($testIntegrationType); $this->typesRegistry->addChannelType($testIntegrationType, new TestIntegrationType()); $this->typesRegistry->addConnectorType($testConnectorType, $testIntegrationType, new TestConnector()); $integration->setEnabled(true); $this->scheduler->schedule($integration, $testConnectorType); }
/** * {@inheritdoc} */ public function load(ObjectManager $manager) { $userManager = $this->container->get('oro_user.manager'); $admin = $userManager->findUserByEmail(LoadAdminUserData::DEFAULT_ADMIN_EMAIL); foreach ($this->data as $data) { $integration = new Integration(); $integration->setName($data['name']); $integration->setType($data['type']); $integration->setEnabled($data['enabled']); $integration->setDefaultUserOwner($admin); $integration->setOrganization($admin->getOrganization()); $this->setReference($data['reference'], $integration); $manager->persist($integration); } $manager->flush(); }
/** * {@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($store); $transport = new MagentoSoapTransport(); $transport->setApiUser('api_user'); $transport->setApiKey('api_key'); $transport->setExtensionVersion(SoapTransport::REQUIRED_EXTENSION_VERSION); $transport->setIsExtensionInstalled(true); $transport->setMagentoVersion('1.9.1.0'); $transport->setWsdlUrl('http://magento.domain'); $om->persist($transport); $integration = new Integration(); $integration->setType('magento'); $integration->setConnectors(['customer', 'cart', 'order', 'newsletter_subscriber']); $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->isEnabled() ? Channel::STATUS_ACTIVE : Channel::STATUS_INACTIVE); $this->dataChannel = $builder->getChannel(); $om->persist($this->dataChannel); $group = new CustomerGroup(); $group->setName('General'); $group->setOriginId(15000); $group->setChannel($integration); $om->persist($group); $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(); $this->persistDemoRFM($om); $om->flush(); }
public function testWithFlush() { $this->assertEmpty($this->getScheduledJobs(), 'Should be empty before test'); $registry = $this->getContainer()->get('oro_integration.manager.types_registry'); $integrationType = uniqid('testIntegrationType', true); $connectorType = uniqid('testConnectorType', true); $registry->addChannelType($integrationType, new TestIntegrationType()); $registry->addConnectorType($connectorType, $integrationType, new TestTwoWayConnector()); $integration = new Integration(); $integration->setType($integrationType); $this->getContainer()->get('oro_integration.sync_scheduler')->schedule($integration, $connectorType); $jobs = $this->getScheduledJobs(); $this->assertNotEmpty($jobs); $this->getContainer()->get('oro_integration.sync_scheduler')->schedule($integration, $connectorType); $jobs = $this->getScheduledJobs(); $this->assertCount(1, $jobs, 'Should check do look up for already scheduled pending jobs'); }
public function testFinishView() { $this->registry->expects($this->once())->method('getAvailableIntegrationTypesDetailedData')->will($this->returnValue(['testType1' => ["label" => "oro.type1.label", "icon" => "bundles/acmedemo/img/logo.png"], 'testType2' => ["label" => "oro.type2.label"]])); $this->assetHelper->expects($this->once())->method('getUrl')->will($this->returnArgument(0)); $testIntegration1 = new Integration(); $testIntegration1->setType('testType1'); $testIntegration1Label = uniqid('label'); $testIntegration1Id = uniqid('id'); $testIntegration2 = new Integration(); $testIntegration2->setType('testType2'); $testIntegration2Label = uniqid('label'); $testIntegration2Id = uniqid('id'); $view = new FormView(); $view->vars['choices'] = [new ChoiceView($testIntegration1, $testIntegration1Id, $testIntegration1Label), new ChoiceView($testIntegration2, $testIntegration2Id, $testIntegration2Label)]; $this->type->finishView($view, $this->getMock('Symfony\\Component\\Form\\Test\\FormInterface'), []); $this->assertEquals($testIntegration1Label, $view->vars['choices'][0]->label); $this->assertEquals($testIntegration2Label, $view->vars['choices'][1]->label); $this->assertEquals(['data-status' => true, 'data-icon' => 'bundles/acmedemo/img/logo.png'], $view->vars['choices'][0]->attr); }
/** * @return $this */ protected function createIntegration() { $integration = new Integration(); $integration->setName('Demo Web store'); $integration->setType('magento'); $integration->setConnectors(["customer", "order", "cart", "region"]); $integration->setTransport($this->transport); $integration->setOrganization($this->organization); $this->em->persist($integration); $this->integration = $integration; return $this; }
protected function prepareEmMock() { $em = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock(); $metadata = $this->getMockBuilder('Doctrine\\ORM\\Mapping\\ClassMetadata')->disableOriginalConstructor()->getMock(); $repo = $this->getMockBuilder('Doctrine\\ORM\\EntityRepository')->disableOriginalConstructor()->getMock(); $entity = new Integration(); $entity->setName(self::TEST_NAME); $entity->setType(self::TEST_TYPE); $this->registry->expects($this->once())->method('getManagerForClass')->with($this->equalTo($this->testEntityName))->will($this->returnValue($em)); $em->expects($this->once())->method('getClassMetadata')->with($this->equalTo($this->testEntityName))->will($this->returnValue($metadata)); $metadata->expects($this->once())->method('getSingleIdentifierFieldName')->will($this->returnValue(self::TEST_ID_FIELD_NAME)); $em->expects($this->once())->method('getRepository')->with($this->equalTo($this->testEntityName))->will($this->returnValue($repo)); $repo->expects($this->once())->method('find')->with($this->equalTo(self::TEST_ID))->will($this->returnValue($entity)); }
/** * @return $this */ protected function createIntegration() { $integration = new Integration(); $integration->setName('Demo Web store'); $integration->setType('magento'); $integration->setConnectors(['customer', 'order', 'cart']); $integration->setTransport($this->transport); $integration->setOrganization($this->organization); $synchronizationSettings = Object::create(['isTwoWaySyncEnabled' => true]); $integration->setSynchronizationSettings($synchronizationSettings); $this->em->persist($integration); $this->integration = $integration; return $this; }