function it_cannot_be_executed_unless_the_job_is_finished(Redis $tx) { $id = '123'; $tx->watch("job:{$id}:txid")->shouldBeCalled(); $tx->zscore('queue:my-queue:failed', $id)->willReturn(null); $tx->zscore('queue:my-queue:succeeded', $id)->willReturn(null); $this->shouldThrow('InvalidArgumentException')->duringExecute(); }
function it_can_be_executed(Redis $tx) { $id = '123'; $now = '2015-04-18T13:16:16.263400+0000'; $tx->watch("job:{$id}:txid")->shouldBeCalled(); $tx->zscore("queue:my-queue:failed", $id)->willReturn(1); $tx->multi()->shouldBeCalled(); $tx->zrem('queue:my-queue:failed', $id)->shouldBeCalled()->willReturn(0); $tx->lpush('queue:my-queue:pending', $id)->shouldBeCalled(); $tx->rpush("job:{$id}:history", Encoder::encode([$now, 'queued']))->shouldBeCalled(); $tx->incr("job:{$id}:tries")->shouldBeCalled(); $tx->incr("job:{$id}:txid")->shouldBeCalled(); $this->execute(); }
function it_can_be_executed(Redis $tx) { $id = '123'; $nowIso = '2015-04-18T13:16:16.263400+0000'; $nowTs = 1429362976.2634; $tx->watch("job:{$id}:txid")->shouldBeCalled(); $tx->zscore('queue:my-queue:succeeded', $id)->willReturn(null); $tx->multi()->shouldBeCalled(); $tx->lrem('queue:my-queue:processing', 1, $id)->shouldBeCalled()->willReturn(1); $tx->zadd('queue:my-queue:failed', $nowTs, $id)->shouldBeCalled(); $tx->rpush("job:{$id}:history", Encoder::encode([$nowIso, 'failed']))->shouldBeCalled(); $tx->incr("job:{$id}:txid")->shouldBeCalled(); $this->execute(); }