Ejemplo n.º 1
0
 public function testBuildsCustomResourceReport()
 {
     $start = '2010-01-01';
     $end = '2010-01-02';
     $resourceId = 1;
     $scheduleId = 2;
     $userId = 3;
     $groupId = 4;
     $accessoryId = 5;
     $participantId = 6;
     $usage = new Report_Usage(Report_Usage::RESOURCES);
     $selection = new Report_ResultSelection(Report_ResultSelection::FULL_LIST);
     $groupBy = new Report_GroupBy(Report_GroupBy::GROUP);
     $range = new Report_Range(Report_Range::DATE_RANGE, $start, $end, 'UTC');
     $filter = new Report_Filter($resourceId, $scheduleId, $userId, $groupId, $accessoryId, $participantId);
     $commandBuilder = new ReportCommandBuilder();
     $commandBuilder->SelectFullList()->OfResources()->Within(Date::Parse($start, 'UTC'), Date::Parse($end, 'UTC'))->WithResourceId($resourceId)->WithUserId($userId)->WithParticipantId($participantId)->WithScheduleId($scheduleId)->WithGroupId($groupId)->WithAccessoryId($accessoryId)->GroupByGroup();
     $rows = array(array(ColumnNames::OWNER_FIRST_NAME => 'value', ColumnNames::OWNER_LAST_NAME => 'value', ColumnNames::OWNER_USER_ID => 'value'));
     $this->reportingRepository->expects($this->once())->method('GetCustomReport')->with($this->equalTo($commandBuilder))->will($this->returnValue($rows));
     $report = $this->rs->GenerateCustomReport($usage, $selection, $groupBy, $range, $filter);
     $cols = new ReportColumns();
     $cols->Add(ColumnNames::OWNER_FIRST_NAME);
     $cols->Add(ColumnNames::OWNER_LAST_NAME);
     $cols->Add(ColumnNames::OWNER_USER_ID);
     $this->assertEquals($cols, $report->GetColumns());
     $this->assertEquals(new CustomReportData($rows), $report->GetData());
 }
Ejemplo n.º 2
0
 public function __construct($rows)
 {
     $this->data = new CustomReportData($rows);
     $this->resultCount = count($rows);
     $this->cols = new ReportColumns();
     if (count($rows) > 0) {
         foreach ($rows[0] as $columnName => $value) {
             $this->cols->Add($columnName);
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * @param array $rows
  * @param IAttributeRepository $attributeRepository
  */
 public function __construct($rows, IAttributeRepository $attributeRepository)
 {
     $this->resultCount = count($rows);
     $this->cols = new ReportColumns();
     if (count($rows) > 0) {
         foreach ($rows[0] as $columnName => $value) {
             if ($columnName == ColumnNames::ATTRIBUTE_LIST) {
                 $attributes = $attributeRepository->GetByCategory(CustomAttributeCategory::RESERVATION);
                 foreach ($attributes as $attribute) {
                     $this->cols->AddAttribute($attribute->Id(), $attribute->Label());
                 }
             } else {
                 $this->cols->Add($columnName);
             }
         }
     }
     $this->data = new CustomReportData($rows);
 }