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()); }
/** * @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)); }
/** * @param CommandInterface $command * @return Job|null * @throws Exception\InvalidArgumentException */ protected function peek(CommandInterface $command) { $this->sync(); return $this->jobFactory->createFromCommand($command, $this->server)->invoke(); }
/** * @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(); }