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 setUp() { $this->transport1 = $this->getMockBuilder('Oro\\Bundle\\IntegrationBundle\\Provider\\TransportInterface')->disableOriginalConstructor()->getMock(); $this->transport2 = clone $this->transport1; $this->typesRegistry = new TypesRegistry(); $this->typesRegistry->addChannelType(self::CHANNEL_TYPE_ONE, new IntegrationTypeWithIcon()); $this->typesRegistry->addTransportType(self::TRANSPORT_TYPE_ONE, self::CHANNEL_TYPE_ONE, $this->transport1); $this->typesRegistry->addChannelType(self::CHANNEL_TYPE_TWO, new IntegrationTypeWithoutIcon()); $this->typesRegistry->addTransportType(self::TRANSPORT_TYPE_TWO, self::CHANNEL_TYPE_TWO, $this->transport2); }
public function testHasTwoWaySyncConnectors() { $testType = 'type2'; $testTypeThatHasConnectors = 'type1'; $this->typesRegistry->addChannelType($testType, new TestIntegrationType()); $this->typesRegistry->addChannelType($testTypeThatHasConnectors, new TestIntegrationType()); $this->typesRegistry->addConnectorType(uniqid('type'), $testType, new TestConnector()); $this->typesRegistry->addConnectorType(uniqid('type'), $testTypeThatHasConnectors, new TestTwoWayConnector()); $this->assertTrue($this->utils->hasTwoWaySyncConnectors($testTypeThatHasConnectors)); $this->assertFalse($this->utils->hasTwoWaySyncConnectors($testType)); }
/** * @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); }
protected function getExtensions() { $assetsHelper = $this->getMockBuilder('Symfony\\Component\\Templating\\Helper\\CoreAssetsHelper')->disableOriginalConstructor()->getMock(); $integrationType = $this->getMock('Oro\\Bundle\\IntegrationBundle\\Provider\\ChannelInterface'); $transportType = $this->getMock('Oro\\Bundle\\IntegrationBundle\\Provider\\TransportInterface'); $registry = new TypesRegistry(); $registry->addChannelType(self::TEST_TYPE, $integrationType); $registry->addTransportType(uniqid('transport'), self::TEST_TYPE, $transportType); $security = $this->getMockBuilder('Oro\\Bundle\\SecurityBundle\\SecurityFacade')->disableOriginalConstructor()->getMock(); $em = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock(); $metadata = $this->getMockBuilder('Doctrine\\ORM\\Mapping\\ClassMetadata')->disableOriginalConstructor()->getMock(); $em->expects($this->once())->method('getClassMetadata')->with($this->equalTo('OroUser:User'))->will($this->returnValue($metadata)); $metadata->expects($this->once())->method('getSingleIdentifierFieldName')->will($this->returnValue(self::TEST_ID_FIELD_NAME)); $searchHandler = $this->getMock('Oro\\Bundle\\FormBundle\\Autocomplete\\SearchHandlerInterface'); $searchHandler->expects($this->any())->method('getEntityName')->will($this->returnValue('OroUser:User')); $searchRegistry = new SearchRegistry(); $searchRegistry->addSearchHandler('acl_users', $searchHandler); $config = $this->getMock('Oro\\Bundle\\EntityConfigBundle\\Config\\ConfigInterface'); $config->expects($this->any())->method('has')->with($this->equalTo('grid_name'))->will($this->returnValue(true)); $config->expects($this->any())->method('get')->with($this->equalTo('grid_name'))->will($this->returnValue('test_grid')); $cp = $this->getMock('Oro\\Bundle\\EntityConfigBundle\\Provider\\ConfigProviderInterface'); $cp->expects($this->any())->method('getConfig')->will($this->returnValue($config)); $cm = $this->getMockBuilder('Oro\\Bundle\\EntityConfigBundle\\Config\\ConfigManager')->disableOriginalConstructor()->getMock(); $cm->expects($this->any())->method('getProvider')->will($this->returnValue($cp)); $validator = new Validator(new ClassMetadataFactory(new LoaderChain([])), new ConstraintValidatorFactory(), new DefaultTranslator()); $settingsProvider = $this->getMockBuilder('OroCRM\\Bundle\\ChannelBundle\\Provider\\SettingsProvider')->disableOriginalConstructor()->getMock(); return [new PreloadedExtension(['oro_integration_channel_form' => $this->getChannelType($registry), 'oro_integration_type_select' => new IntegrationTypeSelectType($registry, $assetsHelper), 'oro_user_organization_acl_select' => new OrganizationUserAclSelectType(), 'oro_user_acl_select' => new UserAclSelectType(), 'oro_entity_create_or_select_inline' => new OroEntitySelectOrCreateInlineType($security, $cm), 'oro_jqueryselect2_hidden' => new OroJquerySelect2HiddenType($em, $searchRegistry, $cp), 'genemu_jqueryselect2_choice' => new Select2Type('choice'), 'genemu_jqueryselect2_hidden' => new Select2Type('hidden')], ['form' => [new FormTypeCsrfExtension($this->getMock('Symfony\\Component\\Form\\Extension\\Csrf\\CsrfProvider\\CsrfProviderInterface')), new FormTypeValidatorExtension($validator), new TooltipFormExtension()], 'oro_integration_channel_form' => [new IntegrationTypeExtension($settingsProvider)]])]; }