Ejemplo n.º 1
0
 function it_can_be_executed(Redis $tx)
 {
     $id = '123';
     $nowTs = 1429362976.2634;
     $nowIso = '2015-04-18T13:16:16.263400+0000';
     $expectedJob = $this->createJob();
     $tx->watch("job:{$id}:txid")->shouldBeCalled();
     $tx->multi()->shouldBeCalled();
     $tx->sadd('queues', 'my-queue')->shouldBeCalled();
     $tx->zadd('jobs', $nowTs, $id)->shouldBeCalled();
     $tx->zrem('queue:my-queue:failed', $id)->shouldBeCalled()->willReturn(0);
     $tx->lpush('queue:my-queue:pending', $id)->shouldBeCalled();
     $tx->setnx("job:{$id}", Encoder::encode($expectedJob))->shouldBeCalled();
     $tx->incr("job:{$id}:tries")->shouldBeCalled();
     $tx->rpush("job:{$id}:history", Encoder::encode([$nowIso, 'queued']))->shouldBeCalled();
     $tx->incr("job:{$id}:txid")->shouldBeCalled();
     $this->execute();
 }