Пример #1
0
 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);
 }
Пример #2
0
 /**
  * @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);
 }