示例#1
0
文件: JobTest.php 项目: zwilias/qman
 public function testJsonEncode_returnsExpectedData()
 {
     $testJob = 'job';
     $testCommand = 'command';
     $expected = json_encode(['job' => $testJob, 'command' => $testCommand]);
     $this->commandMock->expects($this->once())->method('jsonSerialize')->willReturn($testCommand);
     $this->beanieJobMock->expects($this->once())->method('jsonSerialize')->willReturn($testJob);
     $this->assertJsonStringEqualsJsonString($expected, json_encode($this->job));
 }
示例#2
0
 /**
  * @param array $arguments
  * @param string $responseName
  * @param string $expectedState
  * @dataProvider releaseArgumentsProvider
  */
 public function testReleases_dispatchesReleaseCommand_usesArgumentsAndResponseName(array $arguments, $responseName, $expectedState)
 {
     $defaultArgs = [Beanie::DEFAULT_PRIORITY, Beanie::DEFAULT_DELAY];
     $actualArgs = $arguments + $defaultArgs;
     $serverMock = $this->getServerMock(['dispatchCommand']);
     $response = new Response($responseName, null, $serverMock);
     $oath = $this->_getResponseOathMock();
     $oath->expects($this->once())->method('invoke')->willReturn($response);
     $serverMock->expects($this->once())->method('dispatchCommand')->with($this->callback(function (CommandInterface $command) use($actualArgs) {
         return $command->getCommandLine() === sprintf('%s %s %s', CommandInterface::COMMAND_RELEASE, self::TEST_ID, join(' ', $actualArgs));
     }))->willReturn($oath);
     $job = new Job(self::TEST_ID, null, $serverMock);
     call_user_func_array([$job, 'release'], $arguments);
     $this->assertEquals($expectedState, $job->getState());
 }
示例#3
0
文件: Job.php 项目: zwilias/qman
 /**
  * @return $this
  */
 public function delete()
 {
     $this->job->delete();
     return $this;
 }
示例#4
0
文件: Worker.php 项目: zwilias/qman
 /**
  * @param BeanieJob $beanieJob
  * @return Job
  */
 public function createJobFromBeanieJob(BeanieJob $beanieJob)
 {
     return new Job($beanieJob, $this->commandSerializer->unserialize($beanieJob->getData()));
 }