/** * Core test page * * @copyright Copyright (C) 2010-2012 Combodo SARL * @license http://opensource.org/licenses/AGPL-3.0 */ ?> Missing mandatory argument $sName

"; exit; } return $value; } function IsAValidTestClass($sClassName) { // Must be a child of TestHandler // if (!is_subclass_of($sClassName, 'TestHandler')) return false; // Must not be abstract // $oReflectionClass = new ReflectionClass($sClassName); if (!$oReflectionClass->isInstantiable()) return false; return true; } function DisplayEvents($aEvents, $sTitle) { echo "

$sTitle

\n"; if (count($aEvents) > 0) { echo "\n"; } else { echo "

none

\n"; } } /////////////////////////////////////////////////////////////////////////////// // Main /////////////////////////////////////////////////////////////////////////////// require_once('../approot.inc.php'); require_once(APPROOT.'/application/utils.inc.php'); require_once('./test.class.inc.php'); require_once('./testlist.inc.php'); require_once(APPROOT.'/core/cmdbobject.class.inc.php'); $sTodo = utils::ReadParam("todo", ""); if ($sTodo == '') { // Show the list of tests // echo "

Existing tests

\n"; echo "\n"; } else if ($sTodo == 'exec') { // Execute a test // $sTestClass = ReadMandatoryParam("testid"); if (!IsAValidTestClass($sTestClass)) { echo "

Wrong value for testid, expecting a valid class name

\n"; } else { $oTest = new $sTestClass(); echo "

Testing: ".$oTest->GetName()."

\n"; $bRes = $oTest->Execute(); } /* MyHelpers::var_dump_html($oTest->GetResults()); MyHelpers::var_dump_html($oTest->GetWarnings()); MyHelpers::var_dump_html($oTest->GetErrors()); */ if ($bRes) { echo "

Success :-)

\n"; DisplayEvents($oTest->GetResults(), 'Results'); } else { echo "

Failure :-(

\n"; } DisplayEvents($oTest->GetErrors(), 'Errors'); DisplayEvents($oTest->GetWarnings(), 'Warnings'); // Render the output // echo "

Actual output

\n"; echo "
\n"; echo $oTest->GetOutput(); echo "
\n"; } else { } ?>