Diff
Property changes: library/trunk/lib/test
Name: svn:ignore
+ my.run.bat
Modified: library/trunk/lib/test/run.bat (7 => 8)
--- library/trunk/lib/test/run.bat 2006-08-11 18:02:20 UTC (rev 7)
+++ library/trunk/lib/test/run.bat 2006-08-11 18:26:34 UTC (rev 8)
@@ -12,7 +12,7 @@
IF %PHP_BIN% == "" GOTO ERROR1
IF %PHP_INI% == "" GOTO ERROR2
-%PHP_BIN% -c %PHP_INI% runner.class.php %1 %2 %3 %4
+%PHP_BIN% -c %PHP_INI% run.php %1 %2 %3 %4
GOTO END
:ERROR1
Added: library/trunk/lib/test/run.php (7 => 8)
--- library/trunk/lib/test/run.php 2006-08-11 18:02:20 UTC (rev 7)
+++ library/trunk/lib/test/run.php 2006-08-11 18:26:34 UTC (rev 8)
@@ -0,0 +1,34 @@
+#!/usr/bin/php
+<?php
+/**
+ * run.php - defines the test lib directory and runs the testrunner class
+ *
+ * very simply file used to run the testrunner stuff
+ * you can edit the shebang line if your php cli is located elsewhere
+ * on windows you can associate php files with your php cli
+ *
+ * This is released under the GPL, see license.txt for details
+ *
+ * @author Elizabeth Smith <emsmith@callicore.net>
+ * @copyright Elizabeth Smith (c)2006
+ * @link http://callicore.net
+ * @license http://www.opensource.org/licenses/gpl-license.php GPL
+ * @version $Id$
+ * @since Php 5.2.0
+ * @package callicore library
+ * @subpackage test
+ * @category lib
+ * @filesource
+ */
+
+/**
+ * CCL_TEST_LIB is absolute path with slash at end to location of test library files
+ */
+define('CCL_TEST_LIB', dirname(__FILE__) . DIRECTORY_SEPARATOR);
+
+/**
+ * Include and create instance of the test runner class
+ */
+include(CCL_TEST_LIB . 'runner.class.php');
+new CCL_TestRunner();
+?>
\ No newline at end of file
Property changes on: library/trunk/lib/test/run.php
___________________________________________________________________
Name: tsvn:logminsize
+ 15
Name: svn:mime-type
+ text/x-php
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: library/trunk/lib/test/run.sh (7 => 8)
--- library/trunk/lib/test/run.sh 2006-08-11 18:02:20 UTC (rev 7)
+++ library/trunk/lib/test/run.sh 2006-08-11 18:26:34 UTC (rev 8)
@@ -20,5 +20,5 @@
exit 1
fi
-$php_bin -c $php_ini runner.class.php $1 $2 $3 $4
+$php_bin -c $php_ini run.php $1 $2 $3 $4
exit 0
\ No newline at end of file
Added: library/trunk/lib/test/runner.class.php (7 => 8)
--- library/trunk/lib/test/runner.class.php 2006-08-11 18:02:20 UTC (rev 7)
+++ library/trunk/lib/test/runner.class.php 2006-08-11 18:26:34 UTC (rev 8)
@@ -0,0 +1,168 @@
+<?php
+/**
+ * runner.class.php - test runner script
+ *
+ * allows for grouping tests into suits for quick and easy testing
+ *
+ * This is released under the GPL, see license.txt for details
+ *
+ * @author Elizabeth Smith <emsmith@callicore.net>
+ * @copyright Elizabeth Smith (c)2006
+ * @link http://callicore.net
+ * @license http://www.opensource.org/licenses/gpl-license.php GPL
+ * @version $Id$
+ * @since Php 5.2.0
+ * @package callicore library
+ * @subpackage test
+ * @category lib
+ * @filesource
+ */
+
+/**
+ * CCL_TestRunner - designed to be run on the command line to quickly execute tests
+ *
+ * Can be configured with command line args or via an ini file
+ */
+class CCL_TestRunner
+{
+ /**
+ * list of testcases to run
+ * @var $queue array
+ */
+ private $queue = array();
+
+ /**
+ * public function __construct
+ *
+ * discovers if this is being called via the command
+ *
+ * @param type $name about
+ * @return type about
+ */
+ public function __construct()
+ {
+ // configuration - webpage or cli?
+ // cli will look for ini file or command line args
+ // web will look for get/post and/or show form
+ return;
+ }
+
+ /**
+ * public function addTest
+ *
+ * add a testcase or testsuite subclass to the queue
+ *
+ * @param string|object $class name of class or class object
+ * @return void
+ */
+ public function addTest($class)
+ {
+ if (get_parent_class($class) != 'CCL_TestUnit' &&
+ get_parent_class($class) != 'CCL_TestSuite')
+ {
+ throw new Exception(get_class($class) . ' must be a subclass of CCL_TestCase or CCL_TestSuite');
+ return;
+ }
+ if (is_object($class))
+ {
+ $this->queue[] = $class;
+ }
+ else
+ {
+ $this->queue[] = new $class();
+ }
+ return;
+ }
+
+ /**
+ * public function addFile
+ *
+ * add a single file or directory of files - the files are included and
+ * any testsuite or testcase classes are added to the queue
+ *
+ * @param string $filename directory or file to add
+ * @return void
+ */
+ public function addFile($filename)
+ {
+ if (!file_exists($filename))
+ {
+ throw new Exception($filename . ' does not exist and could not be added to the test suite');
+ return;
+ }
+ if (is_file($filename))
+ {
+ $this->includeFile($filename);
+ }
+ elseif (is_dir($filename))
+ {
+ $list = scandir($filename);
+ foreach ($list as $name)
+ {
+ if (is_file($filename . DIRECTORY_SEPARATOR . $name) &&
+ pathinfo($name, PATHINFO_EXTENSION) == 'php' &&
+ !in_array($name{0}, array('.', '~')))
+ {
+ $this->includeFile($filename . DIRECTORY_SEPARATOR . $name);
+ }
+ elseif (is_dir($filename . DIRECTORY_SEPARATOR . $name) &&
+ !in_array($name{0}, array('.', '~')))
+ {
+ $this->addFile($filename . DIRECTORY_SEPARATOR . $name);
+ }
+ }
+ }
+ return;
+ }
+
+ /**
+ * public function run
+ *
+ * runs the tests - this will recurse down like crazy without work :)
+ *
+ * @return void
+ */
+ public function run()
+ {
+ $this->reporter->testSuiteStart($this->name);
+ if (empty($this->queue))
+ {
+ throw new Exception('There are no TestUnits to run');
+ }
+ foreach ($this->queue as $object)
+ {
+ $object->run();
+ }
+ $this->reporter->testSuiteEnd();
+ return;
+ }
+
+ /**
+ * private function includeFile
+ *
+ * includes the file and adds any suite/test children to the queue
+ *
+ * @param string $filename
+ * @return void
+ */
+ private function includeFile($filename)
+ {
+ $prelist = get_declared_classes();
+ include_once ($filename);
+ $postlist = get_declared_classes();
+ $checklist = array_diff($postlist, $prelist);
+ foreach ($checklist as $class)
+ {
+ if (get_parent_class($class) == 'CCL_TestUnit' ||
+ get_parent_class($class) == 'CCL_TestSuite')
+ {
+ $this->queue[] = new $class();
+ }
+ }
+ unset ($prelist, $postlist, $checklist);
+ return;
+ }
+}
+
+
+?>
\ No newline at end of file
Property changes on: library/trunk/lib/test/runner.class.php
___________________________________________________________________
Name: tsvn:logminsize
+ 15
Name: svn:mime-type
+ text/x-php
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native