";
$aClasses = array("archiving/DocumentArchiving" => array("DocumentID", "ArchivingTypeID", "ArchivingSettingsID"),
"archiving/TimeUnit" => array("Name"),
"archiving/ArchivingType" => array("Name"),
"archiving/ArchivingUtilisationSettings" => array("DocumentTransactionID", "TimePeriodID"),
"archiving/TimePeriod" => array("TimeUnitID", "Units"),
"archiving/ArchivingDateSettings" => array("ExpirationDate", "TimePeriodID"));
$aInitialValues = array("1,2,3",
"hour",
"\"blah's\"",
"5, 1",
"1, 10",
"'2002-10-10', 1");
$aSetValues = array(array(9,8,7),
array("minute"),
array("fooblar's"),
array(6,6),
array(2,20),
array("2003-01-01", 4));
$count = 0;
foreach ($aClasses as $classPath => $aMethodList) {
$aClassPath = explode("/", $classPath);
$className = $aClassPath[count($aClassPath)-1];
require_once("$default->fileSystemRoot/lib/$classPath.inc");
$constructor = "\$oClass = new $className($aInitialValues[$count]);";
echo "$className- $constructor
";
echo "Testing creation
";
eval($constructor);
if (isset($oClass)) {
echo "Passed creation test
";
echo "Testing storage
";
if ($oClass->create()) {
echo "Passed storage test
";
$oClass->iId = -1;$oClass->create();
echo "Testing setting and getting of values
";
$i=0;
foreach ($aMethodList as $method) {
$getter = "get$method";
$setter = "set$method";
echo "Current $method: " . $oClass->$getter() . "
";
echo "Setting $method to: " . $aSetValues[$count][$i] . "
";
$oClass->$setter($aSetValues[$count][$i]);
echo "New $method: " . $oClass->$getter() . "
";
$i++;
}
echo "Testing update
";
if ($oClass->update()) {
echo "Passed update test
";
echo "Testing retrieval
";
$get = "\$oNewClass = $className::get(1);";
eval($get);
if ($oNewClass) {
echo "Passed retrieval test:\n" . arrayToString($oNewClass) . "
";
} else {
echo "Failed retrieval test.
";
}
echo "Testing array retrieval
";
$getList = "\$aNewClass = $className::getList();";
eval($getList);
echo "array=\n" . arrayToString($aNewClass) . "
";
echo "Testing deletion
";
if ($oClass->delete()) {
echo "Passed deletion test
";
} else {
echo "Failed deletion test";
}
} else {
echo "Failed update test
";
echo "Tests NOT run: (a) retrieval by id (b) array list retrieval (c) deletion
";
}
} else {
echo "Failed storage test
";
echo "Tests NOT run: (a) update (b) retrieval by id (c) array list retrieval (d) deletion
";
}
} else {
echo "Failed creation test
";
echo "Tests NOT run: (a)getting and setting (b) storage (c) retrieval by id (d) array list retrieval (e) deletion
";
}
$count++;
echo "