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/Router.php | 12 +++++-----
system/libraries/Unit_test.php | 52 ++++++++++++++++++++++++++----------------
user_guide/changelog.html | 1 +
3 files changed, 39 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 = ''.$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 = '
- ';
+ $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".'
';
}
// --------------------------------------------------------------------
diff --git a/user_guide/changelog.html b/user_guide/changelog.html
index 59ab29530..6ed2a2185 100644
--- a/user_guide/changelog.html
+++ b/user_guide/changelog.html
@@ -82,6 +82,7 @@ SVN Commit: not currently released
Added increased security for sessions for client-side data tampering.
The MySQLi forge class is now in sync with MySQL forge.
Added the ability to set CRLF settings via config in the Email class.
+ Unit Testing results are now colour coded, and a change was made to the default template of results.
Helpers
--
cgit v1.2.3-24-g4f1b