/**
  * Testing request grouping.
  *
  * @return void
  */
 public function testRequestGroup()
 {
     $capabilities = ['task1' => ['name' => 'task1', 'timeout' => 1, 'retries' => 2, 'rate' => 0]];
     // create an ungrouped task
     $this->assertTrue((bool) $this->QueuedTasks->createJob('task1', 1));
     //create a Grouped Task
     $this->assertTrue((bool) $this->QueuedTasks->createJob('task1', 2, null, 'testgroup'));
     // Fetching without group should completely ignore the Group field.
     $this->QueuedTasks->clearKey();
     $tmp = $this->QueuedTasks->requestJob($capabilities);
     $this->assertEquals('task1', $tmp['jobtype']);
     $this->assertEquals(1, unserialize($tmp['data']));
     $this->QueuedTasks->clearKey();
     $tmp = $this->QueuedTasks->requestJob($capabilities);
     $this->assertEquals('task1', $tmp['jobtype']);
     $this->assertEquals(2, unserialize($tmp['data']));
     // well, lets tra that Again, while limiting by Group
     // create an ungrouped task
     $this->assertTrue((bool) $this->QueuedTasks->createJob('task1', 3));
     //create a Grouped Task
     $this->assertTrue((bool) $this->QueuedTasks->createJob('task1', 4, null, 'testgroup', 'Job number 4'));
     $this->assertTrue((bool) $this->QueuedTasks->createJob('task1', 5, null, null, 'Job number 5'));
     $this->assertTrue((bool) $this->QueuedTasks->createJob('task1', 6, null, 'testgroup', 'Job number 6'));
     // we should only get tasks 4 and 6, in that order, when requesting inside the group
     $this->QueuedTasks->clearKey();
     $tmp = $this->QueuedTasks->requestJob($capabilities, 'testgroup');
     $this->assertEquals('task1', $tmp['jobtype']);
     $this->assertEquals(4, unserialize($tmp['data']));
     $this->QueuedTasks->clearKey();
     $tmp = $this->QueuedTasks->requestJob($capabilities, 'testgroup');
     $this->assertEquals('task1', $tmp['jobtype']);
     $this->assertEquals(6, unserialize($tmp['data']));
     // use FindProgress on the testgroup:
     $progress = $this->QueuedTasks->find('all', ['conditions' => ['task_group' => 'testgroup']])->toArray();
     $this->assertEquals(3, count($progress));
     $this->assertNull($progress[0]['reference']);
     #$this->assertEquals($progress[0]['status'], 'IN_PROGRESS');
     $this->assertEquals('Job number 4', $progress[1]['reference']);
     #$this->assertEquals($progress[1]['status'], 'IN_PROGRESS');
     $this->assertEquals('Job number 6', $progress[2]['reference']);
     #$this->assertEquals($progress[2]['status'], 'IN_PROGRESS');
 }