Commit 344a21726d3442995bd551add6db617fdf50f4b2
1 parent
41e4e712
updated tests
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@1881 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
113 additions
and
0 deletions
tests/archiving/testSuite.php
0 → 100644
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * Contains unit tests for all classes | ||
| 4 | + * | ||
| 5 | + * Tests are: | ||
| 6 | + * o creation of object | ||
| 7 | + * o setting/getting of values | ||
| 8 | + * o storing of object | ||
| 9 | + * o retrieval of object by primary key | ||
| 10 | + * o retrieval of an array of objects | ||
| 11 | + * o updating of object | ||
| 12 | + * o deletion of object | ||
| 13 | + * @package tests.archiving | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | +require_once("../config/dmsDefaults.php"); | ||
| 17 | + | ||
| 18 | +echo "<pre>"; | ||
| 19 | + | ||
| 20 | +$aClasses = array("archiving/DocumentArchiving" => array("DocumentID", "ArchivingTypeID", "ArchivingSettingsID"), | ||
| 21 | + "archiving/TimeUnit" => array("Name"), | ||
| 22 | + "archiving/ArchivingType" => array("Name"), | ||
| 23 | + "archiving/ArchivingUtilisationSettings" => array("DocumentTransactionID", "TimePeriodID"), | ||
| 24 | + "archiving/TimePeriod" => array("TimeUnitID", "Units"), | ||
| 25 | + "archiving/ArchivingDateSettings" => array("ExpirationDate", "TimePeriodID")); | ||
| 26 | + | ||
| 27 | +$aInitialValues = array("1,2,3", | ||
| 28 | + "hour", | ||
| 29 | + "\"blah's\"", | ||
| 30 | + "5, 1", | ||
| 31 | + "1, 10", | ||
| 32 | + "'2002-10-10', 1"); | ||
| 33 | + | ||
| 34 | +$aSetValues = array(array(9,8,7), | ||
| 35 | + array("minute"), | ||
| 36 | + array("fooblar's"), | ||
| 37 | + array(6,6), | ||
| 38 | + array(2,20), | ||
| 39 | + array("2003-01-01", 4)); | ||
| 40 | + | ||
| 41 | + | ||
| 42 | +$count = 0; | ||
| 43 | +foreach ($aClasses as $classPath => $aMethodList) { | ||
| 44 | + $aClassPath = explode("/", $classPath); | ||
| 45 | + $className = $aClassPath[count($aClassPath)-1]; | ||
| 46 | + require_once("$default->fileSystemRoot/lib/$classPath.inc"); | ||
| 47 | + | ||
| 48 | + $constructor = "\$oClass = new $className($aInitialValues[$count]);"; | ||
| 49 | + echo "<b>$className- $constructor</b><br>"; | ||
| 50 | + echo "<b>Testing creation</b><br>"; | ||
| 51 | + eval($constructor); | ||
| 52 | + if (isset($oClass)) { | ||
| 53 | + echo "Passed creation test<br><br>"; | ||
| 54 | + | ||
| 55 | + echo "<b>Testing storage</b><br>"; | ||
| 56 | + if ($oClass->create()) { | ||
| 57 | + echo "Passed storage test<br><br>"; | ||
| 58 | + $oClass->iId = -1;$oClass->create(); | ||
| 59 | + | ||
| 60 | + echo "<b>Testing setting and getting of values</b><br>"; | ||
| 61 | + $i=0; | ||
| 62 | + foreach ($aMethodList as $method) { | ||
| 63 | + $getter = "get$method"; | ||
| 64 | + $setter = "set$method"; | ||
| 65 | + echo "Current $method: " . $oClass->$getter() . "<br>"; | ||
| 66 | + echo "Setting $method to: " . $aSetValues[$count][$i] . "<br>"; | ||
| 67 | + $oClass->$setter($aSetValues[$count][$i]); | ||
| 68 | + echo "New $method: " . $oClass->$getter() . "<br><br>"; | ||
| 69 | + $i++; | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + echo "<b>Testing update</b><br>"; | ||
| 73 | + if ($oClass->update()) { | ||
| 74 | + echo "Passed update test<br><br>"; | ||
| 75 | + | ||
| 76 | + echo "<b>Testing retrieval</b><br>"; | ||
| 77 | + $get = "\$oNewClass = $className::get(1);"; | ||
| 78 | + eval($get); | ||
| 79 | + if ($oNewClass) { | ||
| 80 | + echo "Passed retrieval test:\n" . arrayToString($oNewClass) . "<br>"; | ||
| 81 | + } else { | ||
| 82 | + echo "Failed retrieval test.<br>"; | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + echo "<b>Testing array retrieval</b><br>"; | ||
| 86 | + $getList = "\$aNewClass = $className::getList();"; | ||
| 87 | + eval($getList); | ||
| 88 | + echo "array=\n" . arrayToString($aNewClass) . "<br><br>"; | ||
| 89 | + | ||
| 90 | + echo "<b>Testing deletion</b><br>"; | ||
| 91 | + if ($oClass->delete()) { | ||
| 92 | + echo "Passed deletion test<br>"; | ||
| 93 | + } else { | ||
| 94 | + echo "Failed deletion test"; | ||
| 95 | + } | ||
| 96 | + } else { | ||
| 97 | + echo "Failed update test<br>"; | ||
| 98 | + echo "Tests NOT run: (a) retrieval by id (b) array list retrieval (c) deletion<br>"; | ||
| 99 | + } | ||
| 100 | + } else { | ||
| 101 | + echo "Failed storage test<br>"; | ||
| 102 | + echo "Tests NOT run: (a) update (b) retrieval by id (c) array list retrieval (d) deletion<br>"; | ||
| 103 | + } | ||
| 104 | + } else { | ||
| 105 | + echo "Failed creation test<br>"; | ||
| 106 | + echo "Tests NOT run: (a)getting and setting (b) storage (c) retrieval by id (d) array list retrieval (e) deletion<br>"; | ||
| 107 | + } | ||
| 108 | + $count++; | ||
| 109 | + echo "<hr>"; | ||
| 110 | +} | ||
| 111 | +echo "</pre>"; | ||
| 112 | + | ||
| 113 | +?> | ||
| 0 | \ No newline at end of file | 114 | \ No newline at end of file |