Пример #1
0
 /**
  * @param CommandInterface $command
  * @param string $tube
  * @param int $priority
  * @param int $delay
  * @param int $timeToRun
  * @throws Exception
  */
 public function queue(CommandInterface $command, $tube = Beanie::DEFAULT_TUBE, $priority = Beanie::DEFAULT_PRIORITY, $delay = Beanie::DEFAULT_DELAY, $timeToRun = Beanie::DEFAULT_TIME_TO_RUN)
 {
     try {
         $this->producer->useTube($tube)->put($this->serializer->serialize($command), $priority, $delay, $timeToRun);
     } catch (Exception $exception) {
         $this->handlePutFailure($exception, $command);
     }
 }
Пример #2
0
 public function testTransformTubeStatusTo_updatesTubeStatus()
 {
     $testTube = new TubeStatus();
     $testTube->setCurrentTube('TEST');
     $testTube->addWatchedTube('TEST');
     /** @var \PHPUnit_Framework_MockObject_MockObject|Pool $poolMock */
     $poolMock = $this->getMockBuilder(Pool::class)->disableOriginalConstructor()->setMethods(['dispatchCommand'])->getMock();
     $poolMock->expects($this->never())->method('dispatchCommand');
     $producer = new Producer($poolMock);
     $producer->transformTubeStatusTo($testTube, TubeStatus::TRANSFORM_BOTH);
     $this->assertEquals($testTube->getCurrentTube(), $producer->getTubeStatus()->getCurrentTube());
     $this->assertEquals($testTube->getWatchedTubes(), $producer->getTubeStatus()->getWatchedTubes());
 }
Пример #3
0
 /**
  * @param array $params
  * @dataProvider queueParamsProvider
  */
 public function testQueueClosure_queues(array $params)
 {
     $closure = function () {
         $this->fail('Should not be executed');
     };
     $testData = 'test';
     $this->serializerMock->expects($this->once())->method('serialize')->with($this->isInstanceOf(ClosureCommand::class))->willReturn($testData);
     $invocationMocker = $this->producerMock->expects($this->once())->method('put');
     call_user_func_array([$invocationMocker, 'with'], array_merge([$testData], $params));
     call_user_func_array([$this->qMan, 'queueClosure'], array_merge([$closure, self::TEST_TUBE], $params));
 }