From f9d5348cf2776374bf09bdda8c941198167d9ae9 Mon Sep 17 00:00:00 2001 From: Derek Allard Date: Sat, 26 Apr 2008 19:19:25 +0000 Subject: Unit Testing results are now colour coded, and a change was made to the default template of results. --- system/libraries/Unit_test.php | 52 ++++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 20 deletions(-) (limited to 'system/libraries/Unit_test.php') diff --git a/system/libraries/Unit_test.php b/system/libraries/Unit_test.php index 33a8f3109..ff4d0c7ed 100644 --- a/system/libraries/Unit_test.php +++ b/system/libraries/Unit_test.php @@ -100,32 +100,48 @@ class CI_Unit_test { * @return string */ function report($result = array()) - { + { if (count($result) == 0) { $result = $this->result(); } - + + $CI =& get_instance(); + $CI->load->language('unit_test'); + $this->_parse_template(); - + $r = ''; foreach ($result as $res) { $table = ''; - + foreach ($res as $key => $val) { - $temp = $this->_template_rows; + + if ($key == $CI->lang->line('ut_result')) + { + if ($val == $CI->lang->line('ut_passed')) + { + $val = ''.$val.''; + } + elseif ($val == $CI->lang->line('ut_failed')) + { + $val = ''.$val.''; + } + } + + $temp = $this->_template_rows; $temp = str_replace('{item}', $key, $temp); $temp = str_replace('{result}', $val, $temp); $table .= $temp; } - + $r .= str_replace('{rows}', $table, $this->_template); } - - return $r; - } + + return $r; + } // -------------------------------------------------------------------- @@ -262,18 +278,14 @@ class CI_Unit_test { */ function _default_template() { - $this->_template = ' -
- - {rows} -
'; + $this->_template = "\n".''; + $this->_template .= '{rows}'; + $this->_template .= "\n".'
'; - $this->_template_rows = ' - - {item} - {result} - - '; + $this->_template_rows = "\n\t".''; + $this->_template_rows .= "\n\t\t".'{item}'; + $this->_template_rows .= "\n\t\t".'{result}'; + $this->_template_rows .= "\n\t".''; } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b