public function itClearsContent() { $data_line = array('Data', 'Data', 'Data'); $statistics_formatter = new Statistics_Formatter('', '', ','); $statistics_formatter->addHeader('Title'); $statistics_formatter->addLine($data_line); $statistics_formatter->addEmptyLine(); $statistics_formatter->clearContent(); $this->assertEqual($statistics_formatter->getCsvContent(), ''); }
/** * Fill statistics by Backend type * * @param Statistics_Formatter $formatter instance of statistics formatter class * @param String $type backend type * @param Array $typeIndex backend type index * @param Array $typeArray backend type array * @param Boolean $keepedAlive keep only reposirtories that still active * * @return Void */ private function fillBackendStatisticsByType(Statistics_Formatter $formatter, $type, $typeIndex, $typeArray, $keepedAlive) { $dao = $this->getDao(); $dar = $dao->getBackendStatistics($type, $formatter->startDate, $formatter->endDate, $formatter->groupId, $keepedAlive); if ($dar && !$dar->isError() && $dar->rowCount() > 0) { foreach ($dar as $row) { $typeIndex[] = $row['month'] . " " . $row['year']; $typeArray[] = intval($row['count']); } $formatter->addLine($typeIndex); $formatter->addLine($typeArray); $formatter->addEmptyLine(); } }
/** * Obtain statistics about backend format for CSV export * * @param Statistics_Formatter $formatter instance of statistics formatter class * * @return String */ public function getBackendStatistics(Statistics_Formatter $formatter) { $dao = $this->getDao(); $formatter->clearContent(); $formatter->addEmptyLine(); $formatter->addHeader('Git'); $gitShellIndex[] = $GLOBALS['Language']->getText('plugin_statistics', 'scm_month'); $gitShell[] = "Git shell"; $gitoliteIndex[] = $GLOBALS['Language']->getText('plugin_statistics', 'scm_month'); $gitolite[] = "Gitolite"; $dar = $dao->getBackendStatistics('gitshell', $formatter->startDate, $formatter->endDate, $formatter->groupId); if ($dar && !$dar->isError() && $dar->rowCount() > 0) { foreach ($dar as $row) { $gitShellIndex[] = $row['month'] . " " . $row['year']; $gitShell[] = intval($row['count']); } $formatter->addLine($gitShellIndex); $formatter->addLine($gitShell); } $dar = $dao->getBackendStatistics('gitolite', $formatter->startDate, $formatter->endDate, $formatter->groupId); if ($dar && !$dar->isError() && $dar->rowCount() > 0) { foreach ($dar as $row) { $gitoliteIndex[] = $row['month'] . " " . $row['year']; $gitolite[] = intval($row['count']); } $formatter->addLine($gitoliteIndex); $formatter->addLine($gitolite); } $this->retrieveLoggedPushesStatistics($formatter); $content = $formatter->getCsvContent(); $formatter->clearContent(); return $content; }