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()); }
public function Add(ReportCommandBuilder $builder) { if ($this->usage == self::ACCESSORIES) { $builder->OfAccessories(); } else { $builder->OfResources(); } }
public function testRunsBuiltCommand() { $builder = new ReportCommandBuilder(); $expected = $builder->Build(); $expectedRows = array(array('c' => 'v')); $this->db->SetRows($expectedRows); $rows = $this->repository->GetCustomReport($builder); $this->assertEquals($expected, $this->db->_LastCommand); $this->assertEquals($expectedRows, $rows); }
/** * @param ReportCommandBuilder $commandBuilder * @return array */ public function GetCustomReport(ReportCommandBuilder $commandBuilder) { $query = $commandBuilder->Build(); $reader = ServiceLocator::GetDatabase()->Query($query); $rows = array(); while ($row = $reader->GetRow()) { $rows[] = $row; } $reader->Free(); return $rows; }
public function Add(ReportCommandBuilder $builder) { if ($this->selection == self::FULL_LIST) { $builder->SelectFullList(); } if ($this->selection == self::COUNT) { $builder->SelectCount(); } if ($this->selection == self::TIME) { $builder->SelectTime(); } }
public function Add(ReportCommandBuilder $builder) { if ($this->groupBy == self::GROUP) { $builder->GroupByGroup(); } if ($this->groupBy == self::SCHEDULE) { $builder->GroupBySchedule(); } if ($this->groupBy == self::USER) { $builder->GroupByUser(); } if ($this->groupBy == self::RESOURCE) { $builder->GroupByResource(); } }
public function Add(ReportCommandBuilder $builder) { if (!empty($this->resourceId)) { $builder->WithResourceId($this->resourceId); } if (!empty($this->scheduleId)) { $builder->WithScheduleId($this->scheduleId); } if (!empty($this->userId)) { $builder->WithUserId($this->userId); } if (!empty($this->participantId)) { $builder->WithParticipantId($this->participantId); } if (!empty($this->groupId)) { $builder->WithGroupId($this->groupId); } if (!empty($this->accessoryId)) { $builder->WithAccessoryId($this->accessoryId); } }
public function Add(ReportCommandBuilder $builder) { if ($this->range != self::ALL_TIME) { $builder->Within($this->start, $this->end); } }
public function testIfGroupByThenNoResourcesAreListed() { $builder = new ReportCommandBuilder(); $actual = $builder->SelectCount()->OfResources()->GroupByGroup()->Build(); $this->assertNotContains(ReportCommandBuilder::RESOURCE_LIST_FRAGMENT, $actual->GetQuery()); $this->assertNotContains(ReportCommandBuilder::RESERVATION_LIST_FRAGMENT, $actual->GetQuery()); }
private function AccessoriesAllTime() { $builder = new ReportCommandBuilder(); $builder->SelectFullList()->OfAccessories(); return $builder; }
public function testThisMonthsAccessories() { $report = new CannedReport(CannedReport::ACCESSORIES_THISMONTH, $this->fakeUser); $range = new Report_Range(Report_Range::CURRENT_MONTH, null, null, $this->fakeUser->Timezone); $builder = $report->GetBuilder(); $expected = new ReportCommandBuilder(); $expected->SelectFullList()->OfAccessories()->Within($range->Start(), $range->End()); $this->assertEquals($expected, $builder); }