Example #1
0
 /**
  * Test what happens if no worker is free
  * @return void
  * @author Andraz <*****@*****.**>
  */
 public function testGetWaitingTaskAndNoFreeWorker()
 {
     $worker = \Mockery::mock('Queue\\Worker');
     $worker->shouldReceive('getType')->once()->andReturn('fibonacci');
     $worker->shouldReceive('isBusy')->once()->andReturn(true);
     $task = \Mockery::mock('Queue\\Task');
     $task->shouldReceive('isWaiting')->once()->andReturn(true);
     $task->shouldReceive('getName')->once()->andReturn('fibonacci');
     $storage = \Mockery::mock('Queue\\SqlStorage');
     $storage->shouldReceive('getTasks')->once()->andReturn([$task]);
     $storage->shouldReceive('getWorkers')->once()->andReturn([$worker]);
     $manager = new Manager($storage, $task);
     list($actualTask, $actualWorker) = $manager->getWaitingTaskAndFreeWorker();
     $this->assertNull($actualTask);
     $this->assertNull($actualWorker);
 }