예제 #1
0
 public function testGetsResourceGroups()
 {
     $scheduleId = 123;
     $groupRows = new ResourceGroupRow();
     $groupRows->With(1, 'group1')->With(2, 'group1a', 1)->With(3, 'group1a1', 2)->With(4, 'group2')->With(5, 'group2a', 4)->With(6, 'group3')->With(7, 'group1b', 1);
     $assignmentRows = new ResourceGroupAssignmentRow();
     $assignmentRows->With(1, 'resource1', 3)->With(2, 'resource2', 3)->With(3, 'resource3', 4)->With(4, 'resource4', 5)->With(5, 'resource5', 5);
     $resourceRows = new FakeResourceAccess();
     $resourceRows->With(1, 'resource1')->With(2, 'resource2')->With(3, 'resource3')->With(4, 'resource4')->With(5, 'resource5');
     $this->db->SetRow(0, $groupRows->Rows());
     $this->db->SetRow(1, $assignmentRows->Rows());
     $this->db->SetRow(2, $resourceRows->Rows());
     $groups = $this->repository->GetResourceGroups($scheduleId, new SkipResource5Filter())->GetGroups();
     $getResourceGroupsCommand = new GetAllResourceGroupsCommand();
     $getResourceGroupAssignments = new GetAllResourceGroupAssignmentsCommand($scheduleId);
     $this->assertEquals(4, count($groups));
     $this->assertEquals(0, $groups[0]->id, 'should have added an "all" group');
     $this->assertEquals('group1', $groups[1]->label);
     $this->assertEquals(1, $groups[1]->id);
     $this->assertEquals(null, $groups[1]->parent_id);
     $this->assertEquals(2, count($groups[1]->children));
     $this->assertEquals(1, count($groups[1]->children[0]));
     $this->assertEquals('group1a', $groups[1]->children[0]->label);
     $this->assertEquals('group1a1', $groups[1]->children[0]->children[0]->label);
     $this->assertEquals('resource1', $groups[1]->children[0]->children[0]->children[0]->label);
     $this->assertEquals('resource2', $groups[1]->children[0]->children[0]->children[1]->label);
     $this->assertEquals('resource3', $groups[2]->children[1]->label);
     $this->assertEquals($getResourceGroupsCommand, $this->db->_Commands[0]);
     $this->assertEquals($getResourceGroupAssignments, $this->db->_Commands[1]);
 }