示例#1
0
 public function testCreateFromCommand_createsJob()
 {
     $serverMock = $this->getServerMock(['dispatchCommand']);
     $command = CommandFactory::instance()->create(CommandInterface::COMMAND_PEEK, [self::TEST_ID]);
     $response = new Response(Response::RESPONSE_FOUND, ['id' => self::TEST_ID, 'data' => self::TEST_DATA], $serverMock);
     $serverMock->expects($this->once())->method('dispatchCommand')->with($this->callback(function (CommandInterface $command) {
         return $command->getCommandLine() == sprintf('%s %s', CommandInterface::COMMAND_PEEK, self::TEST_ID);
     }))->willReturn($this->oath($response));
     $JobFactory = new JobFactory();
     $job = $JobFactory->createFromCommand($command, $serverMock)->invoke();
     $this->assertEquals(Job::STATE_UNKNOWN, $job->getState());
     $this->assertEquals(self::TEST_ID, $job->getId());
     $this->assertEquals(self::TEST_DATA, $job->getData());
 }
示例#2
0
文件: Worker.php 项目: zwilias/beanie
 /**
  * @return JobOath
  * @throws Exception\InvalidArgumentException
  */
 public function reserveOath()
 {
     return $this->jobFactory->createFromCommand($this->commandFactory->create(CommandInterface::COMMAND_RESERVE), $this->server->transformTubeStatusTo($this->getTubeStatus(), TubeStatus::TRANSFORM_WATCHED));
 }
示例#3
0
文件: Tube.php 项目: zwilias/beanie
 /**
  * @param CommandInterface $command
  * @return Job|null
  * @throws Exception\InvalidArgumentException
  */
 protected function peek(CommandInterface $command)
 {
     $this->sync();
     return $this->jobFactory->createFromCommand($command, $this->server)->invoke();
 }
示例#4
0
 /**
  * @param int $jobId
  * @return Job\Job|null
  * @throws Exception\InvalidArgumentException
  */
 public function peek($jobId)
 {
     return $this->jobFactory->createFromCommand($this->commandFactory->create(CommandInterface::COMMAND_PEEK, [$jobId]), $this->server)->invoke();
 }