00001 <?php
00002
00003 define("ENABLE_TESTS", false);
00004
00005 define( "INCLUDE_PLUGIN_TESTS", true );
00006
00007 if(!ENABLE_TESTS){
00008 print "You must change <b>define(\"ENABLE_TESTS\", <font color=\"blue\">false</font>)</b> to <b>define(\"ENABLE_TESTS\", <font color=\"red\">true</font>)</b> at the top of runtests.php to enable the test runner, since it could represent a security risk.";
00009 die;
00010 }
00011
00012 if (!defined( "PLOG_CLASS_PATH" )) {
00013 define( "PLOG_CLASS_PATH", dirname(__FILE__)."/");
00014 }
00015
00016 include_once( PLOG_CLASS_PATH."class/bootstrap.php" );
00017 lt_include( PLOG_CLASS_PATH."class/test/testrunner.class.php" );
00018 lt_include( PLOG_CLASS_PATH."class/test/helpers/htmlreporter.class.php" );
00019 lt_include( PLOG_CLASS_PATH."class/test/helpers/consolereporter.class.php" );
00020 lt_include( PLOG_CLASS_PATH."class/net/http/httpvars.class.php" );
00021
00022
00023 $folders = Array( TEST_CLASS_FOLDER );
00024 if( INCLUDE_PLUGIN_TESTS ) {
00025 lt_include( PLOG_CLASS_PATH."class/plugin/pluginmanager.class.php" );
00026
00027 $pm =& PluginManager::getPluginManager();
00028 $plugins = $pm->getPluginListFromFolder();
00029
00030 foreach( $plugins as $plugin ) {
00031 $folders[] = PLOG_CLASS_PATH."plugins/".$plugin."/class/tests";
00032 }
00033 }
00034
00035
00036
00037
00038 $r = new TestRunner( $folders );
00039
00040
00041 $commandLine = isset( $argv );
00042
00043 if( $commandLine ) {
00044 if( count( $argv ) < 2 ) {
00045
00046 print("\nPlease specify the name of a test suite to run, or 'all' to run all tests in one batch\n\n" );
00047 foreach( $r->getTestSuites() as $suite ) {
00048 print( "* [".$suite->getSuiteName()."]: " );
00049 foreach( $suite->getTestMethods() as $method ) {
00050 print( $method.", ");
00051 }
00052 print( "\n" );
00053 }
00054 }
00055 else {
00056
00057 $r->addListener( new ConsoleReporterListener );
00058 $result = $r->run( $argv );
00059
00060
00061 $reporter = new ConsoleReporter( $result );
00062 print($reporter->generate());
00063 }
00064 }
00065 else {
00066 ?>
00067 <html>
00068 <head>
00069 <title>LifeType Test Suite</title>
00070 </head>
00071 <body>
00072 <?php
00073
00074
00075 $request = HttpVars::getRequest();
00076 $suiteName = isset( $request["suite"] ) ? strtolower($request["suite"]) : "";
00077
00078 if( $suiteName == "" ) {
00079
00080 $suites = $r->getTestSuites();
00081 ?>
00082 <h1>Available Test Suites</h1>
00083 <p>Plese select a test suite to run or click "All" to run all the test suites together.</p>
00084 <table border="1">
00085 <thead>
00086 <th>Suite</th>
00087 <th>Run</th>
00088 <th>Available methods</th>
00089 </thead>
00090 <?php foreach( $suites as $suite ) { ?>
00091 <tr>
00092 <td><?php print( $suite->getSuiteName()) ?></td>
00093 <td><a href="?suite=<?php print( $suite->getSuiteName()) ?>">Run</a></td>
00094 <td><?php foreach( $suite->getTestMethods() as $method ) { print( $method.", " ); } ?></td>
00095 </tr>
00096 <?php } ?>
00097 <tr>
00098 <td>ALL</td>
00099 <td><a href="?suite=all">Run</a></td>
00100 <td> </td>
00101 </tr>
00102 </table>
00103 <?php
00104 }
00105 else {
00106 $result = $r->run( Array( $suiteName ));
00107
00108
00109 $reporter = new HTMLReporter( $result );
00110 print($reporter->generate());
00111 }
00112 ?>
00113 </body>
00114 </html>
00115 <?php } ?>