* @author Romain Quetiez
* @author Denis Flaven
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
?>
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";
foreach ($aEvents as $sEvent)
{
echo "- $sEvent
\n";
}
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";
foreach (get_declared_classes() as $sClassName)
{
if (!IsAValidTestClass($sClassName)) continue;
$sName = call_user_func(array($sClassName, 'GetName'));
$sDescription = call_user_func(array($sClassName, 'GetDescription'));
echo "- $sName ($sDescription)
\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
{
}
?>