summaryrefslogtreecommitdiffstats
path: root/system/libraries/Unit_test.php
diff options
context:
space:
mode:
authorDerek Allard <derek.allard@ellislab.com>2008-04-26 21:19:25 +0200
committerDerek Allard <derek.allard@ellislab.com>2008-04-26 21:19:25 +0200
commitf9d5348cf2776374bf09bdda8c941198167d9ae9 (patch)
tree211a62991776ce1808751f1ccf5f74f365681115 /system/libraries/Unit_test.php
parent2f9559736080f8386fec1bb5a1d99bd9855e2a4d (diff)
Unit Testing results are now colour coded, and a change was made to the default template of results.
Diffstat (limited to 'system/libraries/Unit_test.php')
-rw-r--r--system/libraries/Unit_test.php52
1 files changed, 32 insertions, 20 deletions
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 = '<span style="color: #0C0;">'.$val.'</span>';
+ }
+ elseif ($val == $CI->lang->line('ut_failed'))
+ {
+ $val = '<span style="color: #C00;">'.$val.'</span>';
+ }
+ }
+
+ $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 = '
- <div style="margin:15px;background-color:#ccc;">
- <table border="0" cellpadding="4" cellspacing="1" style="width:100%;">
- {rows}
- </table></div>';
+ $this->_template = "\n".'<table style="width:100%; font-size:small; margin:10px 0; border-collapse:collapse; border:1px solid #CCC;">';
+ $this->_template .= '{rows}';
+ $this->_template .= "\n".'</table>';
- $this->_template_rows = '
- <tr>
- <td style="background-color:#fff;width:140px;font-size:12px;font-weight:bold;">{item}</td>
- <td style="background-color:#fff;font-size:12px;">{result}</td>
- </tr>
- ';
+ $this->_template_rows = "\n\t".'<tr>';
+ $this->_template_rows .= "\n\t\t".'<th style="text-align: left; border-bottom:1px solid #CCC;">{item}</th>';
+ $this->_template_rows .= "\n\t\t".'<td style="border-bottom:1px solid #CCC;">{result}</td>';
+ $this->_template_rows .= "\n\t".'</tr>';
}
// --------------------------------------------------------------------