示例#1
0
 public function testReleasingAndDeletingATask()
 {
     $queue = new Sera_Queue_ArrayQueue();
     $queue->select('myqueue1');
     $queue->enqueue(Sera_Task_Null::create(array('mykey' => 'test1')));
     $task = $queue->dequeue();
     $this->assertTaskData($task, array('mykey' => 'test1'));
     $queue->release($task);
     $task = $queue->dequeue();
     $this->assertTaskData($task, array('mykey' => 'test1'));
     $queue->delete($task);
     $this->assertQueueEmpty($queue);
 }
示例#2
0
 public function testOnFailoverReceivesExceptionFromFailingQueue()
 {
     $badQueue = Mockery::mock();
     $exception = new Sera_Queue_QueueException();
     $badQueue->shouldReceive('enqueue')->once()->andThrow($exception);
     $badQueue->shouldReceive('select')->atLeast()->once();
     $badQueue->shouldReceive('listen')->atLeast()->once();
     $badQueue->shouldReceive('dequeue')->never();
     $goodQueue = Mockery::mock();
     $goodQueue->shouldReceive('select')->atLeast()->once();
     $goodQueue->shouldReceive('listen')->atLeast()->once();
     $goodQueue->shouldReceive('enqueue')->once();
     $failoverQueue = new Sera_Queue_FailoverQueue(array($badQueue, $goodQueue));
     $test = $this;
     $failoverQueue->onFailover(function ($e) use($test) {
         $test->exception = $e;
     });
     $task = Sera_Task_Null::create();
     $failoverQueue->select('test');
     $failoverQueue->enqueue($task);
     $this->assertSame($this->exception, $exception);
 }
示例#3
0
 public function testExecuteTask()
 {
     $task = Sera_Task_Null::create();
     $this->queue->shouldReceive('dequeue')->once()->andReturn($task);
     $this->assertEquals($this->worker->execute(), Sera_Worker::WORKER_SUCCESS);
 }