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