diff options
author | Jonathon Hill <jhill@brandmovers.com> | 2012-11-12 14:51:41 +0100 |
---|---|---|
committer | Jonathon Hill <jhill@brandmovers.com> | 2012-11-12 14:51:41 +0100 |
commit | 3978fc33d82dd7f778d1adbf30744f4dfac41c25 (patch) | |
tree | f32be1ae610f0cfeff65c35abecd14e8ea5cadc6 /system/libraries/Unit_test.php | |
parent | 275cf274860c6ed181d50b398efd3a21d7ba9135 (diff) | |
parent | a9ab46d7a031bda304eb9b6658ffaf693b8d9bcb (diff) |
Merge remote-tracking branch 'upstream/develop' into develop
Conflicts:
user_guide_src/source/changelog.rst
Signed-off-by: Jonathon Hill <jhill@brandmovers.com>
Diffstat (limited to 'system/libraries/Unit_test.php')
-rw-r--r-- | system/libraries/Unit_test.php | 85 |
1 files changed, 53 insertions, 32 deletions
diff --git a/system/libraries/Unit_test.php b/system/libraries/Unit_test.php index 7b99dee0d..842b4aebd 100644 --- a/system/libraries/Unit_test.php +++ b/system/libraries/Unit_test.php @@ -1,4 +1,4 @@ -<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); +<?php /** * CodeIgniter * @@ -24,6 +24,7 @@ * @since Version 1.3.1 * @filesource */ +defined('BASEPATH') OR exit('No direct script access allowed'); /** * Unit Testing Class @@ -38,13 +39,52 @@ */ class CI_Unit_test { + /** + * Active flag + * + * @var bool + */ public $active = TRUE; + + /** + * Test results + * + * @var array + */ public $results = array(); + + /** + * Strict comparison flag + * + * Whether to use === or == when comparing + * + * @var bool + */ public $strict = FALSE; + + /** + * Template + * + * @var string + */ protected $_template = NULL; + + /** + * Template rows + * + * @var string + */ protected $_template_rows = NULL; + + /** + * List of visible test items + * + * @var array + */ protected $_test_items_visible = array(); + // -------------------------------------------------------------------- + /** * Constructor * @@ -92,9 +132,9 @@ class CI_Unit_test { * Runs the supplied tests * * @param mixed $test - * @param mixed $expected = TRUE - * @param string $test_name = 'undefined' - * @param string $notes = '' + * @param mixed $expected + * @param string $test_name + * @param string $notes * @return string */ public function run($test, $expected = TRUE, $test_name = 'undefined', $notes = '') @@ -112,13 +152,13 @@ class CI_Unit_test { } else { - $result = ($this->strict === TRUE) ? ($test === $expected) : ($test === $expected); + $result = ($this->strict === TRUE) ? ($test === $expected) : ($test == $expected); $extype = gettype($expected); } $back = $this->_backtrace(); - $report[] = array ( + $report = array ( 'test_name' => $test_name, 'test_datatype' => gettype($test), 'res_datatype' => $extype, @@ -130,7 +170,7 @@ class CI_Unit_test { $this->results[] = $report; - return $this->report($this->result($report)); + return $this->report($this->result(array($report))); } // -------------------------------------------------------------------- @@ -140,7 +180,7 @@ class CI_Unit_test { * * Displays a table with the test data * - * @param array $result = array() + * @param array $result * @return string */ public function report($result = array()) @@ -220,7 +260,7 @@ class CI_Unit_test { * * Returns the raw result data * - * @param array $results = array() + * @param array $results * @return array */ public function result($results = array()) @@ -244,30 +284,11 @@ class CI_Unit_test { continue; } - if (is_array($val)) - { - foreach ($val as $k => $v) - { - if ( ! in_array($k, $this->_test_items_visible)) - { - continue; - } - - if (FALSE !== ($line = $CI->lang->line(strtolower('ut_'.$v)))) - { - $v = $line; - } - $temp[$CI->lang->line('ut_'.$k)] = $v; - } - } - else + if (FALSE !== ($line = $CI->lang->line(strtolower('ut_'.$val)))) { - if (FALSE !== ($line = $CI->lang->line(strtolower('ut_'.$val)))) - { - $val = $line; - } - $temp[$CI->lang->line('ut_'.$key)] = $val; + $val = $line; } + $temp[$CI->lang->line('ut_'.$key)] = $val; } $retval[] = $temp; @@ -375,4 +396,4 @@ function is_false($test) } /* End of file Unit_test.php */ -/* Location: ./system/libraries/Unit_test.php */
\ No newline at end of file +/* Location: ./system/libraries/Unit_test.php */ |