Commit d8aa49cb5cb40ceb52b65bbed88b14d3dac2fdc7

Authored by Michael Joseph
1 parent c7b8e4c8

update tests


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@2470 c91229c3-7414-0410-bfa2-8a42b809f60b
tests/archiving/show-calendar.gif 0 → 100644

200 Bytes

tests/archiving/testSuite.php
@@ -18,95 +18,99 @@ require_once("../../config/dmsDefaults.php"); @@ -18,95 +18,99 @@ require_once("../../config/dmsDefaults.php");
18 echo "<pre>"; 18 echo "<pre>";
19 19
20 $aClasses = array("archiving/ArchiveRestorationRequest" => array("DocumentID", "RequestUserID", "AdminUserID", "DateTime"), 20 $aClasses = array("archiving/ArchiveRestorationRequest" => array("DocumentID", "RequestUserID", "AdminUserID", "DateTime"),
21 - "archiving/DocumentArchiving" => array("DocumentID", "ArchivingTypeID", "ArchivingSettingsID"), 21 + "archiving/DocumentArchiving" => array("DocumentID", "ArchivingSettingsID"),
22 "archiving/TimeUnit" => array("Name"), 22 "archiving/TimeUnit" => array("Name"),
23 "archiving/ArchivingType" => array("Name"), 23 "archiving/ArchivingType" => array("Name"),
24 - "archiving/ArchivingUtilisationSettings" => array("DocumentTransactionID", "TimePeriodID"),  
25 "archiving/TimePeriod" => array("TimeUnitID", "Units"), 24 "archiving/TimePeriod" => array("TimeUnitID", "Units"),
26 - "archiving/ArchivingDateSettings" => array("ExpirationDate", "TimePeriodID")); 25 + "archiving/ArchivingSettings" => array("ArchivingTypeID", "ExpirationDate", "DocumentTransactionID", "TimePeriodID"));
27 26
28 $aInitialValues = array("1,2,3", 27 $aInitialValues = array("1,2,3",
29 - "1,2,3", 28 + "1,3",
30 "hour", 29 "hour",
31 "\"blah's\"", 30 "\"blah's\"",
32 - "5, 1",  
33 "1, 10", 31 "1, 10",
34 - "'2002-10-10', 1"); 32 + "2, \"2005-15-15\", 5, 1");
35 33
36 $aSetValues = array(array(4,5,6,"2010-10-10"), 34 $aSetValues = array(array(4,5,6,"2010-10-10"),
37 array(9,8,7), 35 array(9,8,7),
38 array("minute"), 36 array("minute"),
39 array("fooblar's"), 37 array("fooblar's"),
40 - array(6,6),  
41 array(2,20), 38 array(2,20),
42 - array("2003-01-01", 4)); 39 + array(3, "2001-02-03", -1, 4));
43 40
44 41
45 -$count = 0; 42 +$count = 0;
  43 +$aTestClasses = array("ArchivingSettings");
  44 +
46 foreach ($aClasses as $classPath => $aMethodList) { 45 foreach ($aClasses as $classPath => $aMethodList) {
47 $aClassPath = explode("/", $classPath); 46 $aClassPath = explode("/", $classPath);
48 $className = $aClassPath[count($aClassPath)-1]; 47 $className = $aClassPath[count($aClassPath)-1];
49 - require_once("$default->fileSystemRoot/lib/$classPath.inc");  
50 -  
51 - $constructor = "\$oClass = new $className($aInitialValues[$count]);";  
52 - echo "<b>$className- $constructor</b><br>";  
53 - echo "<b>Testing creation</b><br>";  
54 - eval($constructor);  
55 - if (isset($oClass)) {  
56 - echo "Passed creation test<br><br>";  
57 -  
58 - echo "<b>Testing storage</b><br>";  
59 - if ($oClass->create()) {  
60 - echo "Passed storage test<br><br>";  
61 - $oClass->iId = -1;$oClass->create();  
62 -  
63 - echo "<b>Testing setting and getting of values</b><br>";  
64 - $i=0;  
65 - foreach ($aMethodList as $method) {  
66 - $getter = "get$method";  
67 - $setter = "set$method";  
68 - echo "Current $method: " . $oClass->$getter() . "<br>";  
69 - echo "Setting $method to: " . $aSetValues[$count][$i] . "<br>";  
70 - $oClass->$setter($aSetValues[$count][$i]);  
71 - echo "New $method: " . $oClass->$getter() . "<br><br>";  
72 - $i++;  
73 - }  
74 -  
75 - echo "<b>Testing update</b><br>";  
76 - if ($oClass->update()) {  
77 - echo "Passed update test<br><br>";  
78 -  
79 - echo "<b>Testing retrieval</b><br>";  
80 - $get = "\$oNewClass = $className::get(1);";  
81 - eval($get);  
82 - if ($oNewClass) {  
83 - echo "Passed retrieval test:\n" . arrayToString($oNewClass) . "<br>";  
84 - } else {  
85 - echo "Failed retrieval test.<br>"; 48 + if (in_array($className, $aTestClasses)) {
  49 +
  50 + require_once("$default->fileSystemRoot/lib/$classPath.inc");
  51 +
  52 + $constructor = "\$oClass = new $className($aInitialValues[$count]);";
  53 + echo "<b>$className- $constructor</b><br>";
  54 + echo "<b>Testing creation</b><br>";
  55 + eval($constructor);
  56 + if (isset($oClass)) {
  57 + echo "Passed creation test<br><br>";
  58 +
  59 + echo "<b>Testing storage</b><br>";
  60 + if ($oClass->create()) {
  61 + echo "Passed storage test<br><br>";
  62 + //$oClass->iId = -1;$oClass->create();
  63 +
  64 + echo "<b>Testing setting and getting of values</b><br>";
  65 + $i=0;
  66 + foreach ($aMethodList as $method) {
  67 + $getter = "get$method";
  68 + $setter = "set$method";
  69 + echo "Current $method: " . $oClass->$getter() . "<br>";
  70 + echo "Setting $method to: " . $aSetValues[$count][$i] . "<br>";
  71 + $oClass->$setter($aSetValues[$count][$i]);
  72 + echo "New $method: " . $oClass->$getter() . "<br><br>";
  73 + $i++;
86 } 74 }
  75 +
  76 + echo "<b>Testing update</b><br>";
  77 + if ($oClass->update()) {
  78 + echo "Passed update test<br><br>";
  79 +
  80 + echo "<b>Testing retrieval</b><br>";
  81 + $get = "\$oNewClass = $className::get(1);";
  82 + eval($get);
  83 + if ($oNewClass) {
  84 + echo "Passed retrieval test:\n" . arrayToString($oNewClass) . "<br>";
  85 + } else {
  86 + echo "Failed retrieval test.<br>";
  87 + }
  88 +
  89 + echo "<b>Testing array retrieval</b><br>";
  90 + $getList = "\$aNewClass = $className::getList();";
  91 + eval($getList);
  92 + echo "array=\n" . arrayToString($aNewClass) . "<br><br>";
87 93
88 - echo "<b>Testing array retrieval</b><br>";  
89 - $getList = "\$aNewClass = $className::getList();";  
90 - eval($getList);  
91 - echo "array=\n" . arrayToString($aNewClass) . "<br><br>";  
92 -  
93 - echo "<b>Testing deletion</b><br>";  
94 - if ($oClass->delete()) {  
95 - echo "Passed deletion test<br>"; 94 + echo "<b>Testing deletion</b><br>";
  95 + if ($oClass->delete()) {
  96 + echo "Passed deletion test<br>";
  97 + } else {
  98 + echo "Failed deletion test";
  99 + }
96 } else { 100 } else {
97 - echo "Failed deletion test";  
98 - } 101 + echo "Failed update test<br>";
  102 + echo "Tests NOT run: (a) retrieval by id (b) array list retrieval (c) deletion<br>";
  103 + }
99 } else { 104 } else {
100 - echo "Failed update test<br>";  
101 - echo "Tests NOT run: (a) retrieval by id (b) array list retrieval (c) deletion<br>";  
102 - } 105 + echo "Failed storage test<br>";
  106 + echo "Tests NOT run: (a) update (b) retrieval by id (c) array list retrieval (d) deletion<br>";
  107 + }
103 } else { 108 } else {
104 - echo "Failed storage test<br>";  
105 - echo "Tests NOT run: (a) update (b) retrieval by id (c) array list retrieval (d) deletion<br>"; 109 + echo "Failed creation test<br>";
  110 + echo "Tests NOT run: (a)getting and setting (b) storage (c) retrieval by id (d) array list retrieval (e) deletion<br>";
106 } 111 }
107 } else { 112 } else {
108 - echo "Failed creation test<br>";  
109 - echo "Tests NOT run: (a)getting and setting (b) storage (c) retrieval by id (d) array list retrieval (e) deletion<br>"; 113 + echo "skipping $className";
110 } 114 }
111 $count++; 115 $count++;
112 echo "<hr>"; 116 echo "<hr>";
tests/authentication/ldap.php 0 → 100644
  1 +<?php
  2 +echo "<pre>";
  3 +$user="michael";
  4 +$password="psychOPomPous03";
  5 +//$password="michael";
  6 +$ldap["domain"]="jamwarehouse.com";
  7 +$ldap["dn"]=$user."@".$ldap["domain"]; //microsoft ldap wants the username@domai
  8 +n for authentication
  9 +//$ldap["dn"]="uid=$user, ou=The Jam Warehouse,ou=External to MRC, o=Medical Res
  10 +earch Council";
  11 +$ldap["ds"]="192.168.1.8"; //ldap server
  12 +if ($ldap["connection"]=ldap_connect($ldap["ds"])) {
  13 + if ($ldap["connection"]) {
  14 + echo "binding to " . $ldap["dn"];
  15 + //if(@ldap_bind($ldap["connection"],$ldap["dn"],$password)) {
  16 + if(@ldap_bind($ldap["connection"])) {
  17 + $result = ldap_search( $ldap["connection"], "CN=Users,DC=jamwarehous
  18 +e,DC=com", "samaccountname=*mi*");
  19 + echo '$result = ldap_search( $ldap["connection"], "CN=Users,DC=jamwa
  20 +rehouse,DC=com", "samaccountname=*mi*");';
  21 + //$result = ldap_search( $ldap["connection"], "o=Medical Research Co
  22 +uncil", "uid=karen");
  23 + $account="samaccountname=".$user;
  24 + //$result = ldap_list($ldap["connection"], "CN=Users,DC=jamwarehouse
  25 +,DC=com", $account);
  26 + $entry = ldap_get_entries($ldap["connection"], $result);
  27 + $fullname=$entry[0]["cn"][0];
  28 + $email=$entry[0]["mail"][0];
  29 + $firstname=$entry[0]["givenname"][0];
  30 + $midname=$entry[0]["initials"][0];
  31 + $lastname=$entry[0]["sn"][0];
  32 +
  33 + //print_r($entry[0]["samaccountname"]);
  34 + print_r($entry);
  35 +
  36 + //print "<BR>Your name is ".$fullname." and your email is ".$email;
  37 + } else {
  38 + print ("<BR><B>Incorrect password or user ".$user." not found.</B><P
  39 +>");
  40 + }
  41 + }
  42 +}
  43 +echo "</pre>";
  44 +?>
0 \ No newline at end of file 45 \ No newline at end of file
tests/documentmanagement/DocumentBrowser.php deleted
1 -<?php  
2 -  
3 -require_once ("../../config/dmsDefaults.php");  
4 -require_once ("$default->fileSystemRoot/lib/documentmanagement/DocumentBrowser.inc");  
5 -  
6 -/**  
7 - * $Id$  
8 - *  
9 - * Unit Tests for lib/documentmanagement/DocumentBrowser.inc  
10 - * includes tests for:  
11 - * browseByFolder($folderID)  
12 - * browseByCategory($category)  
13 - * browseByDocumentType($documentTypeID)  
14 - *  
15 - * Licensed under the GNU GPL. For full terms see the file COPYING.  
16 - *  
17 - * @version $Revision$  
18 - * @author Michael Joseph <michael@jamwarehouse.com>, Jam Warehouse (Pty) Ltd, South Africa  
19 - * @package tests.documentmanagement  
20 - */  
21 -  
22 -// -------------------------------  
23 -// page start  
24 -// -------------------------------  
25 -  
26 -if (checkSession()) {  
27 -  
28 - echo "<pre>";  
29 - $db = new DocumentBrowser();  
30 -  
31 - // default browse- should resolve to root folder  
32 - echo "default browse- starts at this users root folder<br>";  
33 - $artifacts = $db->browseByFolder();  
34 - if (!is_null($_SESSION["errorMessage"])) {  
35 - echo "error: " . $_SESSION["errorMessage"] . "<br>";  
36 - $_SESSION["errorMessage"] = NULL;  
37 - }  
38 - print_r($artifacts);  
39 -  
40 - // now supply a folderid  
41 - $folderID = 3;  
42 - echo "browse- starting at folder (folderID=$folderID)<br>";  
43 - $artifacts = $db->browseByFolder($folderID);  
44 - if (!is_null($_SESSION["errorMessage"])) {  
45 - echo "error: " . $_SESSION["errorMessage"] . "<br>";  
46 - $_SESSION["errorMessage"] = NULL;  
47 - }  
48 - print_r($artifacts);  
49 -  
50 - // browse by category  
51 - echo "category browse- return a list of categories:<br>";  
52 - $results = $db->browseByCategory();  
53 - if (!is_null($_SESSION["errorMessage"])) {  
54 - echo "error: " . $_SESSION["errorMessage"] . "<br>";  
55 - $_SESSION["errorMessage"] = NULL;  
56 - }  
57 - print_r($results);  
58 -  
59 - // pick the first category  
60 - $category = $results["categories"][0];  
61 - echo "browsing by category = $category<br>";  
62 - $artifacts = $db->browseByCategory($category);  
63 - if (!is_null($_SESSION["errorMessage"])) {  
64 - echo "error: " . $_SESSION["errorMessage"] . "<br>";  
65 - $_SESSION["errorMessage"] = NULL;  
66 - }  
67 - print_r($artifacts);  
68 -  
69 - // document type browsing  
70 - echo "document type browse- get list of doc types<br>";  
71 - $results = $db->browseByDocumentType();  
72 - if (!is_null($_SESSION["errorMessage"])) {  
73 - echo "error: " . $_SESSION["errorMessage"] . "<br>";  
74 - $_SESSION["errorMessage"] = NULL;  
75 - }  
76 - print_r($results);  
77 -  
78 - // pick the first document type id  
79 - srand ((float) microtime() * 10000000);  
80 - $documentTypeID = $results["documentTypes"][0]["id"];  
81 - $documentTypeName = $results["documentTypes"][0]["name"];  
82 - echo "browsing by document type = $documentTypeID; name=$documentTypeName<br>";  
83 - $artifacts = $db->browseByDocumentType($documentTypeID);  
84 - if (!is_null($_SESSION["errorMessage"])) {  
85 - echo "error: " . $_SESSION["errorMessage"] . "<br>";  
86 - $_SESSION["errorMessage"] = NULL;  
87 - }  
88 - print_r($artifacts);  
89 -  
90 - echo "</pre>";  
91 -} else {  
92 - // FIXME: redirect to no permission page  
93 - print "you do not have access to view this page! please go away, and come back when you do.<br>";  
94 - echo generateLink("logout") . "logout</a>";  
95 -}  
96 -?>