Permalink
Browse files

Converted to tabs and added usage

  • Loading branch information...
1 parent e1d5a49 commit 81abbcf42bedf7242ba9d2a52a0235fab5fa6689 @ericbarnes committed Nov 5, 2011
Showing with 41 additions and 42 deletions.
  1. +8 −0 README.md
  2. +16 −17 unit_test.php
  3. +17 −25 unit_test_xml.php
View
@@ -35,6 +35,14 @@ All test files need to be named `test_name_folder.php`. For example:
I have included a full download of simpletest and the only customization I have made is to the `simpletest/extensions/my_reporter.php`.
+## Usage:
+
+Once you have installed you can either run tests through the browser or via command line.
+
+* Browser - Visit yoursite.com/unit_test.php
+* Command Link - `$ php unit_test.php`
+* XML Results - `$ php unit_test_xml.php`
+
### NOTES:
Inside the "tests" directory I include two example test files. The test_users_model.php will not run on its own because your application would not include the same users model as the example file. It is supplied just as a guide.
View
@@ -36,9 +36,9 @@ public function __construct($name = '')
}
public function __get($var)
- {
+ {
return $this->_ci->$var;
- }
+ }
}
class CodeIgniterWebTestCase extends WebTestCase {
@@ -51,9 +51,9 @@ public function __construct($name = '')
}
public function __get($var)
- {
+ {
return $this->_ci->$var;
- }
+ }
}
// Because get is removed in ci we pull it out here.
@@ -63,8 +63,6 @@ public function __get($var)
$run_all = TRUE;
}
-
-
//Capture CodeIgniter output, discard and load system into $CI variable
ob_start();
include(ROOT . 'index.php');
@@ -76,7 +74,6 @@ public function __get($var)
$CI->load->helper('directory');
-
// Get all main tests
if ($run_all OR ( ! empty($_POST) && ! isset($_POST['test'])))
{
@@ -119,20 +116,20 @@ public function __get($var)
*/
function setup_cli($argv)
{
- if (php_sapi_name() == 'cli')
+ if (php_sapi_name() == 'cli')
{
- if(isset($argv[1]))
+ if(isset($argv[1]))
{
if(stripos($argv[1],'.php') !== false)
{
$_POST['test'] = $argv[1];
- }
- else
+ }
+ else
{
$_POST[$argv[1]] = $argv[1];
}
}
- else
+ else
{
$_POST['all'] = 'all';
}
@@ -180,9 +177,11 @@ function map_tests($location = '')
$form_url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
//display the form
-if ($cli_mode) {
- exit ($test_suite->run(new TextReporter()) ? 0 : 1);
-}
-else {
- include(TESTS_DIR . 'test_gui.php');
+if ($cli_mode)
+{
+ exit ($test_suite->run(new TextReporter()) ? 0 : 1);
}
+else
+{
+ include(TESTS_DIR . 'test_gui.php');
+}
View
@@ -44,9 +44,9 @@ public function __construct($name = '')
}
public function __get($var)
- {
+ {
return $this->_ci->$var;
- }
+ }
}
class CodeIgniterWebTestCase extends WebTestCase {
@@ -59,9 +59,9 @@ public function __construct($name = '')
}
public function __get($var)
- {
+ {
return $this->_ci->$var;
- }
+ }
}
// Because get is removed in ci we pull it out here.
@@ -71,8 +71,6 @@ public function __get($var)
$run_all = TRUE;
}
-
-
//Capture CodeIgniter output, discard and load system into $CI variable
ob_start();
include(ROOT . 'index.php');
@@ -81,10 +79,8 @@ public function __get($var)
$CI->load->library('session');
$CI->session->sess_destroy();
-
$CI->load->helper('directory');
-
// Get all main tests
if ($run_all OR ( ! empty($_POST) && ! isset($_POST['test'])))
{
@@ -127,20 +123,20 @@ public function __get($var)
*/
function setup_cli($argv)
{
- if (php_sapi_name() == 'cli')
+ if (php_sapi_name() == 'cli')
{
- if(isset($argv[1]))
+ if(isset($argv[1]))
{
if(stripos($argv[1],'.php') !== false)
{
$_POST['test'] = $argv[1];
- }
- else
+ }
+ else
{
$_POST[$argv[1]] = $argv[1];
}
}
- else
+ else
{
$_POST['all'] = 'all';
}
@@ -187,15 +183,11 @@ function map_tests($location = '')
$helpers = map_tests(TESTS_DIR . 'helpers');
$form_url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
-//display the form
-//if ($cli_mode) {
-// exit ($test_suite->run(new TextReporter()) ? 0 : 1);
-//}
-//else {
-// include(TESTS_DIR . 'test_gui.php');
-//}
-
-if($cli_mode) {
- exit ($test_suite->run(new XMLtimeReporter()) ? 0 : 1); }
- else {
- include(TESTS_DIR . 'test_gui.php');}
+if ($cli_mode)
+{
+ exit ($test_suite->run(new XMLtimeReporter()) ? 0 : 1);
+}
+else
+{
+ include(TESTS_DIR . 'test_gui.php');
+}

0 comments on commit 81abbcf

Please sign in to comment.