Example #1
0
 /**
  * @return int Status code to exit with
  */
 public function run()
 {
     $queue = $this->context->argv->get(1);
     if (!$queue) {
         $this->stdio->outln('<<red>>No queue specified<<reset>>');
         return Status::USAGE;
     }
     while (call_user_func($this->listener)) {
         $this->consumer->consume($queue);
     }
     return Status::SUCCESS;
 }
Example #2
0
 public function testConsumeWithJob()
 {
     $command = Phake::mock(CommandInterface::class);
     $class = get_class($command);
     $options = ['foo' => 'bar'];
     $job = json_encode(['command' => $class, 'options' => $options]);
     Phake::when($command)->withOptions(Phake::anyParameters())->thenReturn($command);
     Phake::when($this->client)->lpop($this->queue)->thenReturn($job);
     Phake::when($this->resolver)->__invoke($class)->thenReturn($command);
     $this->consumer->consume($this->queue);
     Phake::verify($this->client)->lpop($this->queue);
     Phake::verify($command)->withOptions($options);
     Phake::verify($command)->execute();
 }