Exemplo n.º 1
0
 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));
 }
Exemplo n.º 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());
 }
Exemplo n.º 3
0
Arquivo: Job.php Projeto: zwilias/qman
 /**
  * @return $this
  */
 public function delete()
 {
     $this->job->delete();
     return $this;
 }
Exemplo n.º 4
0
 /**
  * @param BeanieJob $beanieJob
  * @return Job
  */
 public function createJobFromBeanieJob(BeanieJob $beanieJob)
 {
     return new Job($beanieJob, $this->commandSerializer->unserialize($beanieJob->getData()));
 }