summaryrefslogtreecommitdiffstats
path: root/system/libraries/Unit_test.php
diff options
context:
space:
mode:
authorBarry Mieny <barry@mieny.com>2010-10-04 16:33:58 +0200
committerBarry Mieny <barry@mieny.com>2010-10-04 16:33:58 +0200
commitdd6719738936be31cdaa1758ca86d5eb14dcab3d (patch)
treeb5ef66e31b2d0f4f2c1cbccc367bde92c156e1f9 /system/libraries/Unit_test.php
parent3351fbc56cea19ec3dd603836beb0a420b1ded65 (diff)
Cleanup of stray spaces and tabs
Diffstat (limited to 'system/libraries/Unit_test.php')
-rw-r--r--system/libraries/Unit_test.php110
1 files changed, 55 insertions, 55 deletions
diff --git a/system/libraries/Unit_test.php b/system/libraries/Unit_test.php
index c47143637..9a90cb47c 100644
--- a/system/libraries/Unit_test.php
+++ b/system/libraries/Unit_test.php
@@ -29,9 +29,9 @@
class CI_Unit_test {
var $active = TRUE;
- var $results = array();
+ var $results = array();
var $strict = FALSE;
- var $_template = NULL;
+ var $_template = NULL;
var $_template_rows = NULL;
var $_test_items_visible = array();
@@ -82,32 +82,32 @@ class CI_Unit_test {
* @param mixed
* @param string
* @return string
- */
+ */
function run($test, $expected = TRUE, $test_name = 'undefined', $notes = '')
{
if ($this->active == FALSE)
{
return FALSE;
}
-
+
if (in_array($expected, array('is_object', 'is_string', 'is_bool', 'is_true', 'is_false', 'is_int', 'is_numeric', 'is_float', 'is_double', 'is_array', 'is_null'), TRUE))
{
$expected = str_replace('is_float', 'is_double', $expected);
- $result = ($expected($test)) ? TRUE : FALSE;
+ $result = ($expected($test)) ? TRUE : FALSE;
$extype = str_replace(array('true', 'false'), 'bool', str_replace('is_', '', $expected));
}
else
{
if ($this->strict == TRUE)
- $result = ($test === $expected) ? TRUE : FALSE;
+ $result = ($test === $expected) ? TRUE : FALSE;
else
- $result = ($test == $expected) ? TRUE : FALSE;
-
+ $result = ($test == $expected) ? TRUE : FALSE;
+
$extype = gettype($expected);
}
-
+
$back = $this->_backtrace();
-
+
$report[] = array (
'test_name' => $test_name,
'test_datatype' => gettype($test),
@@ -124,7 +124,7 @@ class CI_Unit_test {
}
// --------------------------------------------------------------------
-
+
/**
* Generate a report
*
@@ -175,9 +175,9 @@ class CI_Unit_test {
return $r;
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Use strict comparison
*
@@ -191,9 +191,9 @@ class CI_Unit_test {
{
$this->strict = ($state == FALSE) ? FALSE : TRUE;
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Make Unit testing active
*
@@ -207,9 +207,9 @@ class CI_Unit_test {
{
$this->active = ($state == FALSE) ? FALSE : TRUE;
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Result Array
*
@@ -219,15 +219,15 @@ class CI_Unit_test {
* @return array
*/
function result($results = array())
- {
+ {
$CI =& get_instance();
$CI->load->language('unit_test');
-
+
if (count($results) == 0)
{
$results = $this->results;
}
-
+
$retval = array();
foreach ($results as $result)
{
@@ -246,8 +246,8 @@ class CI_Unit_test {
if (FALSE !== ($line = $CI->lang->line(strtolower('ut_'.$v))))
{
$v = $line;
- }
- $temp[$CI->lang->line('ut_'.$k)] = $v;
+ }
+ $temp[$CI->lang->line('ut_'.$k)] = $v;
}
}
else
@@ -255,19 +255,19 @@ class CI_Unit_test {
if (FALSE !== ($line = $CI->lang->line(strtolower('ut_'.$val))))
{
$val = $line;
- }
+ }
$temp[$CI->lang->line('ut_'.$key)] = $val;
}
}
-
+
$retval[] = $temp;
}
-
+
return $retval;
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Set the template
*
@@ -276,14 +276,14 @@ class CI_Unit_test {
* @access public
* @param string
* @return void
- */
+ */
function set_template($template)
{
$this->_template = $template;
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Generate a backtrace
*
@@ -297,17 +297,17 @@ class CI_Unit_test {
if (function_exists('debug_backtrace'))
{
$back = debug_backtrace();
-
+
$file = ( ! isset($back['1']['file'])) ? '' : $back['1']['file'];
$line = ( ! isset($back['1']['line'])) ? '' : $back['1']['line'];
-
+
return array('file' => $file, 'line' => $line);
}
return array('file' => 'Unknown', 'line' => 'Unknown');
}
// --------------------------------------------------------------------
-
+
/**
* Get Default Template
*
@@ -315,17 +315,17 @@ class CI_Unit_test {
* @return string
*/
function _default_template()
- {
+ {
$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 = "\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>';
+ $this->_template_rows .= "\n\t".'</tr>';
}
-
+
// --------------------------------------------------------------------
/**
@@ -336,29 +336,29 @@ class CI_Unit_test {
* @access private
* @return void
*/
- function _parse_template()
- {
- if ( ! is_null($this->_template_rows))
- {
- return;
- }
-
- if (is_null($this->_template))
- {
- $this->_default_template();
- return;
- }
-
+ function _parse_template()
+ {
+ if ( ! is_null($this->_template_rows))
+ {
+ return;
+ }
+
+ if (is_null($this->_template))
+ {
+ $this->_default_template();
+ return;
+ }
+
if ( ! preg_match("/\{rows\}(.*?)\{\/rows\}/si", $this->_template, $match))
{
- $this->_default_template();
- return;
+ $this->_default_template();
+ return;
}
$this->_template_rows = $match['1'];
- $this->_template = str_replace($match['0'], '{rows}', $this->_template);
- }
-
+ $this->_template = str_replace($match['0'], '{rows}', $this->_template);
+ }
+
}
// END Unit_test Class