Commit 6cff93bed0f282e0ccedfacfa8e7b7f36c719013

Authored by rob
1 parent a85c082b

Finished unit testing for documentManagement.inc with relation to document types.


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@105 c91229c3-7414-0410-bfa2-8a42b809f60b
tests/documentmanagement/documentTypeTest.php
... ... @@ -25,12 +25,17 @@ global $default;
25 25  
26 26 $docManager = new DocumentManager();
27 27  
  28 +$docManager->deleteDocumentType("Test Document");
  29 +$docManager->deleteDocumentTypeField("Test Field");
  30 +
  31 +echo "<b>Testing creation of document types</b><br>";
28 32 if ($docManager->createDocumentType("Test")) {
29 33 echo "Passed document type creation test<br>";
30 34 } else {
31 35 echo "Failed 'document type creation' test: " . $default->errorMessage . "<br>";
32 36 }
33 37  
  38 +echo "<b>Testing creation of duplicate document types</b><br>";
34 39 //test creation of duplicate document types
35 40 if (!$docManager->createDocumentType("Test")) {
36 41 echo "Passed 'duplicate document type creation' test<br>";
... ... @@ -38,6 +43,7 @@ if (!$docManager-&gt;createDocumentType(&quot;Test&quot;)) {
38 43 echo "Failed duplicate document type creation test<br>";
39 44 }
40 45  
  46 +echo "<b>Testing deletion of document types</b><br>";
41 47 //test deletion of an existing document type
42 48 if ($docManager->deleteDocumentType("Test")) {
43 49 echo "Passed 'existing document type deletion' test<br>";
... ... @@ -45,6 +51,7 @@ if ($docManager-&gt;deleteDocumentType(&quot;Test&quot;)) {
45 51 echo "Failed existing document type deletion test<br>";
46 52 }
47 53  
  54 +echo "<b>Testing deletion of non-existant document types</b><br>";
48 55 //test deletion of a document type that doesn't exist
49 56 if (!$docManager->deleteDocumentType("Does not exist")) {
50 57 echo "Passed 'deletion of non-existing document type' test<br>";
... ... @@ -58,6 +65,7 @@ if (!$docManager-&gt;deleteDocumentType(&quot;Does not exist&quot;)) {
58 65 *
59 66 */
60 67  
  68 +echo "<b>Testing creation of document field types</b><br>";
61 69 //test creation of a field
62 70 if ($docManager->createDocumentTypeField("Test Field","VARCHAR")) {
63 71 echo "Passed 'creation of document type field' test<br>";
... ... @@ -65,6 +73,7 @@ if ($docManager-&gt;createDocumentTypeField(&quot;Test Field&quot;,&quot;VARCHAR&quot;)) {
65 73 echo "Failed 'creation of document type field' test<br>";
66 74 }
67 75  
  76 +echo "<b>Testing creation of duplicate document field types</b><br>";
68 77 //test creation of duplicate field
69 78 if (!($docManager->createDocumentTypeField("Test Field","VARCHAR"))) {
70 79 echo "Passed 'creation of duplicate document type field ' test<br>";
... ... @@ -72,6 +81,7 @@ if (!($docManager-&gt;createDocumentTypeField(&quot;Test Field&quot;,&quot;VARCHAR&quot;))) {
72 81 echo "Failed 'creation of duplicated document type field ' test<br>: $default->errorMessage";
73 82 }
74 83  
  84 +echo "<b>Testing deletion of document field types</b><br>";
75 85 //test deletion of a field
76 86 if ($docManager->deleteDocumentTypeField("Test Field")) {
77 87 echo "Passed 'deletion of document type field ' test<br>";
... ... @@ -79,6 +89,7 @@ if ($docManager-&gt;deleteDocumentTypeField(&quot;Test Field&quot;)) {
79 89 echo "Failed 'deletion of document type field ' test<<br>";
80 90 }
81 91  
  92 +echo "<b>Testing deletion of non-existant document types</b><br>";
82 93 //test deletion of a non-existant field
83 94 if (!$docManager->deleteDocumentTypeField("Test Field that doesn't exist")) {
84 95 echo "Passed 'deletion of non-existant document type field ' test<br>";
... ... @@ -86,8 +97,38 @@ if (!$docManager-&gt;deleteDocumentTypeField(&quot;Test Field that doesn&#39;t exist&quot;)) {
86 97 echo "Failed 'deletion of non-existant document type field ' test<<br>";
87 98 }
88 99  
  100 +/**
  101 +*
  102 +* Document type, document field type link test
  103 +*
  104 +*/
89 105  
  106 +echo "<b>Testing linking of document types and document field types</b><br>";
  107 +//test the linking of a document to a document field type
  108 +$docManager->createDocumentType("Test Document");
  109 +$docManager->createDocumentTypeField("Test Field", "VARCHAR");
  110 +
  111 +$documentTypeID = $docManager->getDocumentTypeID("Test Document");
  112 +$documentTypeFieldID = $docManager->getDocumentTypeFieldID("Test Field");
  113 +if (!(is_bool($documentTypeID)) && !(is_bool($documentTypeField))) {
  114 + echo "Passed document type and document type field id retreival test<br>";
  115 + if ($docManager->createDocumentTypeFieldLink($documentTypeID, $documentTypeFieldID, true)) {
  116 + echo "Passed linking of document types and document field types test<br>";
  117 + } else {
  118 + echo "Passed linking of document types and document field types test: " . $default->errorMessage . "<br>";
  119 + }
  120 +} else {
  121 + echo "Failed document type and document type field id retreival test: " . $default->errorMessage . "<br>";
  122 +}
90 123  
  124 +echo "<b>Testing deletion of link between document types and document field types</b><br>";
  125 +if ($docManager->deleteDocumentTypeFieldLink($documentTypeID, $documentTypeFieldID)) {
  126 + echo "Passed deletion of link between document types and document field types<br>";
  127 +} else {
  128 + echo "Failed deletion of link between document types and document field types<br>";
  129 +}
91 130  
  131 +$docManager->deleteDocumentType("Test Document");
  132 +$docManager->deleteDocumentTypeField("Test Field");
92 133  
93 134 ?>
... ...