Commit 6cff93bed0f282e0ccedfacfa8e7b7f36c719013
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
Showing
1 changed file
with
41 additions
and
0 deletions
tests/documentmanagement/documentTypeTest.php
| @@ -25,12 +25,17 @@ global $default; | @@ -25,12 +25,17 @@ global $default; | ||
| 25 | 25 | ||
| 26 | $docManager = new DocumentManager(); | 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 | if ($docManager->createDocumentType("Test")) { | 32 | if ($docManager->createDocumentType("Test")) { |
| 29 | echo "Passed document type creation test<br>"; | 33 | echo "Passed document type creation test<br>"; |
| 30 | } else { | 34 | } else { |
| 31 | echo "Failed 'document type creation' test: " . $default->errorMessage . "<br>"; | 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 | //test creation of duplicate document types | 39 | //test creation of duplicate document types |
| 35 | if (!$docManager->createDocumentType("Test")) { | 40 | if (!$docManager->createDocumentType("Test")) { |
| 36 | echo "Passed 'duplicate document type creation' test<br>"; | 41 | echo "Passed 'duplicate document type creation' test<br>"; |
| @@ -38,6 +43,7 @@ if (!$docManager->createDocumentType("Test")) { | @@ -38,6 +43,7 @@ if (!$docManager->createDocumentType("Test")) { | ||
| 38 | echo "Failed duplicate document type creation test<br>"; | 43 | echo "Failed duplicate document type creation test<br>"; |
| 39 | } | 44 | } |
| 40 | 45 | ||
| 46 | +echo "<b>Testing deletion of document types</b><br>"; | ||
| 41 | //test deletion of an existing document type | 47 | //test deletion of an existing document type |
| 42 | if ($docManager->deleteDocumentType("Test")) { | 48 | if ($docManager->deleteDocumentType("Test")) { |
| 43 | echo "Passed 'existing document type deletion' test<br>"; | 49 | echo "Passed 'existing document type deletion' test<br>"; |
| @@ -45,6 +51,7 @@ if ($docManager->deleteDocumentType("Test")) { | @@ -45,6 +51,7 @@ if ($docManager->deleteDocumentType("Test")) { | ||
| 45 | echo "Failed existing document type deletion test<br>"; | 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 | //test deletion of a document type that doesn't exist | 55 | //test deletion of a document type that doesn't exist |
| 49 | if (!$docManager->deleteDocumentType("Does not exist")) { | 56 | if (!$docManager->deleteDocumentType("Does not exist")) { |
| 50 | echo "Passed 'deletion of non-existing document type' test<br>"; | 57 | echo "Passed 'deletion of non-existing document type' test<br>"; |
| @@ -58,6 +65,7 @@ if (!$docManager->deleteDocumentType("Does not exist")) { | @@ -58,6 +65,7 @@ if (!$docManager->deleteDocumentType("Does not exist")) { | ||
| 58 | * | 65 | * |
| 59 | */ | 66 | */ |
| 60 | 67 | ||
| 68 | +echo "<b>Testing creation of document field types</b><br>"; | ||
| 61 | //test creation of a field | 69 | //test creation of a field |
| 62 | if ($docManager->createDocumentTypeField("Test Field","VARCHAR")) { | 70 | if ($docManager->createDocumentTypeField("Test Field","VARCHAR")) { |
| 63 | echo "Passed 'creation of document type field' test<br>"; | 71 | echo "Passed 'creation of document type field' test<br>"; |
| @@ -65,6 +73,7 @@ if ($docManager->createDocumentTypeField("Test Field","VARCHAR")) { | @@ -65,6 +73,7 @@ if ($docManager->createDocumentTypeField("Test Field","VARCHAR")) { | ||
| 65 | echo "Failed 'creation of document type field' test<br>"; | 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 | //test creation of duplicate field | 77 | //test creation of duplicate field |
| 69 | if (!($docManager->createDocumentTypeField("Test Field","VARCHAR"))) { | 78 | if (!($docManager->createDocumentTypeField("Test Field","VARCHAR"))) { |
| 70 | echo "Passed 'creation of duplicate document type field ' test<br>"; | 79 | echo "Passed 'creation of duplicate document type field ' test<br>"; |
| @@ -72,6 +81,7 @@ if (!($docManager->createDocumentTypeField("Test Field","VARCHAR"))) { | @@ -72,6 +81,7 @@ if (!($docManager->createDocumentTypeField("Test Field","VARCHAR"))) { | ||
| 72 | echo "Failed 'creation of duplicated document type field ' test<br>: $default->errorMessage"; | 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 | //test deletion of a field | 85 | //test deletion of a field |
| 76 | if ($docManager->deleteDocumentTypeField("Test Field")) { | 86 | if ($docManager->deleteDocumentTypeField("Test Field")) { |
| 77 | echo "Passed 'deletion of document type field ' test<br>"; | 87 | echo "Passed 'deletion of document type field ' test<br>"; |
| @@ -79,6 +89,7 @@ if ($docManager->deleteDocumentTypeField("Test Field")) { | @@ -79,6 +89,7 @@ if ($docManager->deleteDocumentTypeField("Test Field")) { | ||
| 79 | echo "Failed 'deletion of document type field ' test<<br>"; | 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 | //test deletion of a non-existant field | 93 | //test deletion of a non-existant field |
| 83 | if (!$docManager->deleteDocumentTypeField("Test Field that doesn't exist")) { | 94 | if (!$docManager->deleteDocumentTypeField("Test Field that doesn't exist")) { |
| 84 | echo "Passed 'deletion of non-existant document type field ' test<br>"; | 95 | echo "Passed 'deletion of non-existant document type field ' test<br>"; |
| @@ -86,8 +97,38 @@ if (!$docManager->deleteDocumentTypeField("Test Field that doesn't exist")) { | @@ -86,8 +97,38 @@ if (!$docManager->deleteDocumentTypeField("Test Field that doesn't exist")) { | ||
| 86 | echo "Failed 'deletion of non-existant document type field ' test<<br>"; | 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 | ?> |