diff options
author | Derek Allard <derek.allard@ellislab.com> | 2008-04-26 21:19:25 +0200 |
---|---|---|
committer | Derek Allard <derek.allard@ellislab.com> | 2008-04-26 21:19:25 +0200 |
commit | f9d5348cf2776374bf09bdda8c941198167d9ae9 (patch) | |
tree | 211a62991776ce1808751f1ccf5f74f365681115 /system/libraries | |
parent | 2f9559736080f8386fec1bb5a1d99bd9855e2a4d (diff) |
Unit Testing results are now colour coded, and a change was made to the default template of results.
Diffstat (limited to 'system/libraries')
-rw-r--r-- | system/libraries/Router.php | 12 | ||||
-rw-r--r-- | system/libraries/Unit_test.php | 52 |
2 files changed, 38 insertions, 26 deletions
diff --git a/system/libraries/Router.php b/system/libraries/Router.php index d9dd6dd3f..804e80bd2 100644 --- a/system/libraries/Router.php +++ b/system/libraries/Router.php @@ -204,7 +204,7 @@ class CI_Router { // Does the requested controller exist in the sub-folder?
if ( ! file_exists(APPPATH.'controllers/'.$this->fetch_directory().$segments[0].EXT))
{
- show_404($this->fetch_directory().$segments[0]);
+ show_404($this->fetch_directory().$segments[0]);
}
}
else
@@ -220,16 +220,16 @@ class CI_Router { }
}
-
+
return $segments;
}
-
+
// Can't find the requested controller...
- show_404($segments[0]);
+ show_404($segments[0]);
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Parse Routes
*
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>';
}
// --------------------------------------------------------------------
|