From 6ef83d0e058d653322a8f9eb1131e665fb9b2a70 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Mon, 29 Feb 2016 22:40:26 -0500 Subject: Add unit test for transition model --- app/Model/TransitionExport.php | 76 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 app/Model/TransitionExport.php (limited to 'app/Model/TransitionExport.php') diff --git a/app/Model/TransitionExport.php b/app/Model/TransitionExport.php new file mode 100644 index 00000000..33becb82 --- /dev/null +++ b/app/Model/TransitionExport.php @@ -0,0 +1,76 @@ +getColumns()); + $transitions = $this->transition->getAllByProjectAndDate($project_id, $from, $to); + + foreach ($transitions as $transition) { + $results[] = $this->format($transition); + } + + return $results; + } + + /** + * Get column titles + * + * @access protected + * @return string[] + */ + protected function getColumns() + { + return array( + e('Id'), + e('Task Title'), + e('Source column'), + e('Destination column'), + e('Executer'), + e('Date'), + e('Time spent'), + ); + } + + /** + * Format the output of a transition array + * + * @access protected + * @param array $transition + * @return array + */ + protected function format(array $transition) + { + $values = array( + (int) $transition['id'], + $transition['title'], + $transition['src_column'], + $transition['dst_column'], + $transition['name'] ?: $transition['username'], + date($this->config->get('application_datetime_format', DateParser::DATE_TIME_FORMAT), $transition['date']), + round($transition['time_spent'] / 3600, 2) + ); + + return $values; + } +} -- cgit v1.2.3