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); }
/** * @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(); }
/** * @param Integration $integration * * @return \Symfony\Component\HttpFoundation\RedirectResponse * @Route("/toggle/{id}", requirements={"id"="\d+"}, name="oro_integration_toggle") * @Acl( * id="oro_integration_toggle", * type="entity", * permission="EDIT", * class="OroIntegrationBundle:Channel" * ) */ public function toggleAction(Integration $integration) { if ($integration->getEnabled()) { $integration->setEnabled(false); $this->get('session')->getFlashBag()->add('success', $this->get('translator')->trans('oro.integration.controller.integration.message.deactivated')); } else { $integration->setEnabled(true); $this->get('session')->getFlashBag()->add('success', $this->get('translator')->trans('oro.integration.controller.integration.message.activated')); } $em = $this->get('doctrine.orm.entity_manager'); $em->persist($integration); $em->flush($integration); return $this->redirect($this->generateUrl('oro_integration_update', ['id' => $integration->getid(), '_enableContentProviders' => 'mainMenu'])); }
public function dataTest() { $testContact = new ExtendContact(); $testContactAddress = new ContactAddress(); $testContactEmail = new ContactEmail(); $testContactPhone = new ContactPhone(); $testContactAddress->setOwner($testContact); $testContactEmail->setOwner($testContact); $testContactPhone->setOwner($testContact); $testMagentoCustomer = new ExtendCustomer(); $channel = new Channel(); $channel->getSynchronizationSettingsReference()->offsetSet('isTwoWaySyncEnabled', true); $channel->setName('test'); $channel->setEnabled(true); $testMagentoCustomer->setChannel($channel); return ['Updated contact' => [$testContact, $testMagentoCustomer, $channel, [], [$testContact], [], true, true, true, true, true], 'Inserted contact' => [$testContact, $testMagentoCustomer, $channel, [$testContact], [], [], true, false, false, true, false], 'Deleted contact' => [$testContact, $testMagentoCustomer, $channel, [], [], [$testContact], true, true, true, false, true], 'Updated contact with testContactAddress' => [$testContact, $testMagentoCustomer, $channel, [], [$testContact, $testContactAddress], [], true, true, true, true, true], 'Test process Contact Address' => [$testContact, $testMagentoCustomer, $channel, [], [$testContactAddress], [], true, true, true, false, true], 'Test deleted Contact Address' => [$testContact, $testMagentoCustomer, $channel, [], [], [$testContactAddress], true, true, true, false, true]]; }