Commit a3a24885c3f9744ad1edcea6cc7e123a28d01c5d
1 parent
6f16851b
Tests for document addition logic in KTDocumentUtil
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3598 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
5 changed files
with
358 additions
and
0 deletions
tests/document/add.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +require_once("../../config/dmsDefaults.php"); | ||
| 4 | +require_once(KT_LIB_DIR . '/documentmanagement/documentutil.inc.php'); | ||
| 5 | +require_once(KT_LIB_DIR . '/filelike/fsfilelike.inc.php'); | ||
| 6 | + | ||
| 7 | +error_reporting(E_ALL); | ||
| 8 | + | ||
| 9 | +$oFolder =& Folder::get(1); | ||
| 10 | +$oUser =& User::get(1); | ||
| 11 | + | ||
| 12 | +$sLocalname = KT_DIR . "/tests/document/dataset1/critique-of-pure-reason.txt"; | ||
| 13 | +$sFilename = tempnam("/tmp", "kt_tests_document_add"); | ||
| 14 | +copy($sLocalname, $sFilename); | ||
| 15 | + | ||
| 16 | +/* | ||
| 17 | +$oDocument =& KTDocumentUtil::add($oFolder, "testquickupload.txt", $oUser, array( | ||
| 18 | + 'contents' => new KTFSFileLike($sFilename), | ||
| 19 | +)); | ||
| 20 | + | ||
| 21 | +if (PEAR::isError($oDocument)) { | ||
| 22 | + print "FAILURE\n"; | ||
| 23 | + var_dump($oDocument); | ||
| 24 | + exit(0); | ||
| 25 | +} | ||
| 26 | +*/ | ||
| 27 | + | ||
| 28 | +if (!file_exists($sFilename)) { | ||
| 29 | + copy($sLocalname, $sFilename); | ||
| 30 | +} | ||
| 31 | + | ||
| 32 | +$oDocument =& KTDocumentUtil::add($oFolder, "newtest2.txt", $oUser, array()); | ||
| 33 | +if (PEAR::isError($oDocument)) { | ||
| 34 | + print "FAILURE\n"; | ||
| 35 | + var_dump($oDocument); | ||
| 36 | +} | ||
| 37 | + | ||
| 38 | +/* | ||
| 39 | + | ||
| 40 | +$res = KTDocumentUtil::storeContents($oDocument, new KTFSFileLike($sFilename)); | ||
| 41 | +var_dump($res); | ||
| 42 | + | ||
| 43 | +if (file_exists($sFilename)) { | ||
| 44 | + unlink($sFilename); | ||
| 45 | +} | ||
| 46 | + | ||
| 47 | +$oDocument->setStatusID(LIVE); | ||
| 48 | +$oDocument->update(); | ||
| 49 | +*/ | ||
| 50 | + | ||
| 51 | +?> |
tests/document/addInOneGo.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +require_once("../../config/dmsDefaults.php"); | ||
| 4 | +require_once(KT_LIB_DIR . '/documentmanagement/documentutil.inc.php'); | ||
| 5 | +require_once(KT_LIB_DIR . '/filelike/fsfilelike.inc.php'); | ||
| 6 | + | ||
| 7 | +error_reporting(E_ALL); | ||
| 8 | + | ||
| 9 | +$oFolder =& Folder::get(1); | ||
| 10 | +$oUser =& User::get(1); | ||
| 11 | + | ||
| 12 | +$sLocalname = KT_DIR . "/tests/document/dataset1/critique-of-pure-reason.txt"; | ||
| 13 | +$sFilename = tempnam("/tmp", "kt_tests_document_add"); | ||
| 14 | +copy($sLocalname, $sFilename); | ||
| 15 | + | ||
| 16 | +DBUtil::startTransaction(); | ||
| 17 | +$oDocument =& KTDocumentUtil::add($oFolder, "testfullupload2.txt", $oUser, array( | ||
| 18 | + 'contents' => new KTFSFileLike($sFilename), | ||
| 19 | + 'metadata' => array(), | ||
| 20 | +)); | ||
| 21 | + | ||
| 22 | +if (PEAR::isError($oDocument)) { | ||
| 23 | + print "FAILURE\n"; | ||
| 24 | + var_dump($oDocument); | ||
| 25 | + exit(0); | ||
| 26 | +} | ||
| 27 | +DBUtil::commit(); | ||
| 28 | + | ||
| 29 | +print "SUCCESS\n"; | ||
| 30 | + | ||
| 31 | +?> |
tests/document/dataset1/critique-of-pure-reason.txt
0 → 100644
| 1 | +THE CRITIQUE OF PURE REASON | ||
| 2 | + | ||
| 3 | +by Immanuel Kant | ||
| 4 | + | ||
| 5 | +translated by J. M. D. Meiklejohn | ||
| 6 | + | ||
| 7 | + | ||
| 8 | + | ||
| 9 | +PREFACE TO THE FIRST EDITION, 1781 | ||
| 10 | + | ||
| 11 | +Human reason, in one sphere of its cognition, is called upon to | ||
| 12 | +consider questions, which it cannot decline, as they are presented | ||
| 13 | +by its own nature, but which it cannot answer, as they transcend every | ||
| 14 | +faculty of the mind. | ||
| 15 | + | ||
| 16 | +It falls into this difficulty without any fault of its own. It | ||
| 17 | +begins with principles, which cannot be dispensed with in the field | ||
| 18 | +of experience, and the truth and sufficiency of which are, at the same | ||
| 19 | +time, insured by experience. With these principles it rises, in | ||
| 20 | +obedience to the laws of its own nature, to ever higher and more | ||
| 21 | +remote conditions. But it quickly discovers that, in this way, its | ||
| 22 | +labours must remain ever incomplete, because new questions never cease | ||
| 23 | +to present themselves; and thus it finds itself compelled to have | ||
| 24 | +recourse to principles which transcend the region of experience, while | ||
| 25 | +they are regarded by common sense without distrust. It thus falls into | ||
| 26 | +confusion and contradictions, from which it conjectures the presence | ||
| 27 | +of latent errors, which, however, it is unable to discover, because | ||
| 28 | +the principles it employs, transcending the limits of experience, | ||
| 29 | +cannot be tested by that criterion. The arena of these endless | ||
| 30 | +contests is called Metaphysic. | ||
| 31 | + | ||
| 32 | +Time was, when she was the queen of all the sciences; and, if we | ||
| 33 | +take the will for the deed, she certainly deserves, so far as | ||
| 34 | +regards the high importance of her object-matter, this title of | ||
| 35 | +honour. Now, it is the fashion of the time to heap contempt and | ||
| 36 | +scorn upon her; and the matron mourns, forlorn and forsaken, like | ||
| 37 | +Hecuba: | ||
| 38 | + | ||
| 39 | + Modo maxima rerum, | ||
| 40 | + Tot generis, natisque potens... | ||
| 41 | + Nunc trahor exul, inops. | ||
| 42 | + -- Ovid, Metamorphoses. xiii | ||
| 43 | + | ||
| 44 | +At first, her government, under the administration of the | ||
| 45 | +dogmatists, was an absolute despotism. But, as the legislative | ||
| 46 | +continued to show traces of the ancient barbaric rule, her empire | ||
| 47 | +gradually broke up, and intestine wars introduced the reign of | ||
| 48 | +anarchy; while the sceptics, like nomadic tribes, who hate a permanent | ||
| 49 | +habitation and settled mode of living, attacked from time to time | ||
| 50 | +those who had organized themselves into civil communities. But their | ||
| 51 | +number was, very happily, small; and thus they could not entirely | ||
| 52 | +put a stop to the exertions of those who persisted in raising new | ||
| 53 | +edifices, although on no settled or uniform plan. In recent times | ||
| 54 | +the hope dawned upon us of seeing those disputes settled, and the | ||
| 55 | +legitimacy of her claims established by a kind of physiology of the | ||
| 56 | +human understanding--that of the celebrated Locke. But it was found | ||
| 57 | +that--although it was affirmed that this so-called queen could not | ||
| 58 | +refer her descent to any higher source than that of common experience, | ||
| 59 | +a circumstance which necessarily brought suspicion on her claims--as | ||
| 60 | +this genealogy was incorrect, she persisted in the advancement of | ||
| 61 | +her claims to sovereignty. Thus metaphysics necessarily fell back into | ||
| 62 | +the antiquated and rotten constitution of dogmatism, and again | ||
| 63 | +became obnoxious to the contempt from which efforts had been made to | ||
| 64 | +save it. At present, as all methods, according to the general | ||
| 65 | +persuasion, have been tried in vain, there reigns nought but weariness | ||
| 66 | +and complete indifferentism--the mother of chaos and night in the | ||
| 67 | +scientific world, but at the same time the source of, or at least | ||
| 68 | +the prelude to, the re-creation and reinstallation of a science, | ||
| 69 | +when it has fallen into confusion, obscurity, and disuse from ill | ||
| 70 | +directed effort. | ||
| 71 | + | ||
| 72 | +For it is in reality vain to profess indifference in regard to | ||
| 73 | +such inquiries, the object of which cannot be indifferent to humanity. | ||
| 74 | +Besides, these pretended indifferentists, however much they may try | ||
| 75 | +to disguise themselves by the assumption of a popular style and by | ||
| 76 | +changes on the language of the schools, unavoidably fall into | ||
| 77 | +metaphysical declarations and propositions, which they profess to | ||
| 78 | +regard with so much contempt. At the same time, this indifference, | ||
| 79 | +which has arisen in the world of science, and which relates to that | ||
| 80 | +kind of knowledge which we should wish to see destroyed the last, is | ||
| 81 | +a phenomenon that well deserves our attention and reflection. It is | ||
| 82 | +plainly not the effect of the levity, but of the matured judgement* | ||
| 83 | +of the age, which refuses to be any longer entertained with illusory | ||
| 84 | +knowledge, It is, in fact, a call to reason, again to undertake the | ||
| 85 | +most laborious of all tasks--that of self-examination, and to | ||
| 86 | +establish a tribunal, which may secure it in its well-grounded claims, | ||
| 87 | +while it pronounces against all baseless assumptions and | ||
| 88 | +pretensions, not in an arbitrary manner, but according to its own | ||
| 89 | +eternal and unchangeable laws. This tribunal is nothing less than | ||
| 90 | +the critical investigation of pure reason. | ||
| 91 | + | ||
| 92 | +[*Footnote: We very often hear complaints of the shallowness of the | ||
| 93 | +present age, and of the decay of profound science. But I do not think | ||
| 94 | +that those which rest upon a secure foundation, such as mathematics, | ||
| 95 | +physical science, etc., in the least deserve this reproach, but that | ||
| 96 | +they rather maintain their ancient fame, and in the latter case, | ||
| 97 | +indeed, far surpass it. The same would be the case with the other | ||
| 98 | +kinds of cognition, if their principles were but firmly established. | ||
| 99 | +In the absence of this security, indifference, doubt, and finally, | ||
| 100 | +severe criticism are rather signs of a profound habit of thought. | ||
| 101 | +Our age is the age of criticism, to which everything must be | ||
| 102 | +subjected. The sacredness of religion, and the authority of | ||
| 103 | +legislation, are by many regarded as grounds of exemption from the | ||
| 104 | +examination of this tribunal. But, if they on they are exempted, | ||
| 105 | +they become the subjects of just suspicion, and cannot lay claim to | ||
| 106 | +sincere respect, which reason accords only to that which has stood | ||
| 107 | +the test of a free and public examination.] | ||
| 108 | + | ||
| 109 | +I do not mean by this a criticism of books and systems, but a | ||
| 110 | +critical inquiry into the faculty of reason, with reference to the | ||
| 111 | +cognitions to which it strives to attain without the aid of | ||
| 112 | +experience; in other words, the solution of the question regarding | ||
| 113 | +the possibility or impossibility of metaphysics, and the determination | ||
| 114 | +of the origin, as well as of the extent and limits of this science. | ||
| 115 | +All this must be done on the basis of principles. | ||
| 116 | + | ||
| 117 | +This path--the only one now remaining--has been entered upon by | ||
| 118 | +me; and I flatter myself that I have, in this way, discovered the | ||
| 119 | +cause of--and consequently the mode of removing--all the errors | ||
| 120 | +which have hitherto set reason at variance with itself, in the | ||
| 121 | +sphere of non-empirical thought. I have not returned an evasive answer | ||
| 122 | +to the questions of reason, by alleging the inability and limitation | ||
| 123 | +of the faculties of the mind; I have, on the contrary, examined them | ||
| 124 | +completely in the light of principles, and, after having discovered | ||
| 125 | +the cause of the doubts and contradictions into which reason fell, | ||
| 126 | +have solved them to its perfect satisfaction. It is true, these | ||
| 127 | +questions have not been solved as dogmatism, in its vain fancies and | ||
| 128 | +desires, had expected; for it can only be satisfied by the exercise | ||
| 129 | +of magical arts, and of these I have no knowledge. But neither do these | ||
| 130 | +come within the compass of our mental powers; and it was the duty of | ||
| 131 | +philosophy to destroy the illusions which had their origin in | ||
| 132 | +misconceptions, whatever darling hopes and valued expectations may | ||
| 133 | +be ruined by its explanations. My chief aim in this work has been | ||
| 134 | +thoroughness; and I make bold to say that there is not a single | ||
| 135 | +metaphysical problem that does not find its solution, or at least | ||
| 136 | +the key to its solution, here. Pure reason is a perfect unity; and | ||
| 137 | +therefore, if the principle presented by it prove to be insufficient | ||
| 138 | +for the solution of even a single one of those questions to which | ||
| 139 | +the very nature of reason gives birth, we must reject it, as we could | ||
| 140 | +not be perfectly certain of its sufficiency in the case of the others. | ||
| 141 | + | ||
| 142 | +While I say this, I think I see upon the countenance of the reader | ||
| 143 | +signs of dissatisfaction mingled with contempt, when he hears | ||
| 144 | +declarations which sound so boastful and extravagant; and yet they | ||
| 145 | +are beyond comparison more moderate than those advanced by the commonest | ||
| 146 | +author of the commonest philosophical programme, in which the | ||
| 147 | +dogmatist professes to demonstrate the simple nature of the soul, or | ||
| 148 | +the necessity of a primal being. Such a dogmatist promises to extend | ||
| 149 | +human knowledge beyond the limits of possible experience; while I | ||
| 150 | +humbly confess that this is completely beyond my power. Instead of | ||
| 151 | +any such attempt, I confine myself to the examination of reason alone | ||
| 152 | +and its pure thought; and I do not need to seek far for the | ||
| 153 | +sum-total of its cognition, because it has its seat in my own mind. | ||
| 154 | +Besides, common logic presents me with a complete and systematic | ||
| 155 | +catalogue of all the simple operations of reason; and it is my task | ||
| 156 | +to answer the question how far reason can go, without the material | ||
| 157 | +presented and the aid furnished by experience. | ||
| 158 | + | ||
| 159 | +So much for the completeness and thoroughness necessary in the | ||
| 160 | +execution of the present task. The aims set before us are not | ||
| 161 | +arbitrarily proposed, but are imposed upon us by the nature of | ||
| 162 | +cognition itself. | ||
| 163 | + | ||
| 164 | +The above remarks relate to the matter of our critical inquiry. As | ||
| 165 | +regards the form, there are two indispensable conditions, which any | ||
| 166 | +one who undertakes so difficult a task as that of a critique of pure | ||
| 167 | +reason, is bound to fulfil. These conditions are certitude and | ||
| 168 | +clearness. | ||
| 169 | + | ||
| 170 | +As regards certitude, I have fully convinced myself that, in this | ||
| 171 | +sphere of thought, opinion is perfectly inadmissible, and that | ||
| 172 | +everything which bears the least semblance of an hypothesis must be | ||
| 173 | +excluded, as of no value in such discussions. For it is a necessary | ||
| 174 | +condition of every cognition that is to be established upon a priori | ||
| 175 | +grounds that it shall be held to be absolutely necessary; much more | ||
| 176 | +is this the case with an attempt to determine all pure a priori | ||
| 177 | +cognition, and to furnish the standard--and consequently an example-- | ||
| 178 | +of all apodeictic (philosophical) certitude. Whether I have | ||
| 179 | +succeeded in what I professed to do, it is for the reader to | ||
| 180 | +determine; it is the author's business merely to adduce grounds and | ||
| 181 | +reasons, without determining what influence these ought to have on | ||
| 182 | +the mind of his judges. But, lest anything he may have said may become | ||
| 183 | +the innocent cause of doubt in their minds, or tend to weaken the effect | ||
| 184 | +which his arguments might otherwise produce--he may be allowed to | ||
| 185 | +point out those passages which may occasion mistrust or difficulty, | ||
| 186 | +although these do not concern the main purpose of the present work. | ||
| 187 | +He does this solely with the view of removing from the mind of the | ||
| 188 | +reader any doubts which might affect his judgement of the work as a | ||
| 189 | +whole, and in regard to its ultimate aim. | ||
| 190 | + | ||
| 191 | +I know no investigations more necessary for a full insight into | ||
| 192 | +the nature of the faculty which we call understanding, and at the same | ||
| 193 | +time for the determination of the rules and limits of its use, than | ||
| 194 | +those undertaken in the second chapter of the "Transcendental | ||
| 195 | +Analytic," under the title of "Deduction of the Pure Conceptions of | ||
| 196 | +the Understanding"; and they have also cost me by far the greatest | ||
| 197 | +labour--labour which, I hope, will not remain uncompensated. The | ||
| 198 | +view there taken, which goes somewhat deeply into the subject, has | ||
| 199 | +two sides, The one relates to the objects of the pure understanding, | ||
| 200 | +and is intended to demonstrate and to render comprehensible the | ||
| 201 | +objective validity of its a priori conceptions; and it forms for | ||
| 202 | +this reason an essential part of the Critique. The other considers | ||
| 203 | +the pure understanding itself, its possibility and its powers of | ||
| 204 | +cognition--that is, from a subjective point of view; and, although | ||
| 205 | +this exposition is of great importance, it does not belong essentially | ||
| 206 | +to the main purpose of the work, because the grand question is what | ||
| 207 | +and how much can reason and understanding, apart from experience, | ||
| 208 | +cognize, and not, how is the faculty of thought itself possible? As | ||
| 209 | +the latter is an, inquiry into the cause of a given effect, and has | ||
| 210 | +thus in it some semblance of an hypothesis (although, as I shall | ||
| 211 | +show on another occasion, this is really not the fact), it would | ||
| 212 | +seem that, in the present instance, I had allowed myself to enounce | ||
| 213 | +a mere opinion, and that the reader must therefore be at liberty to | ||
| 214 | +hold a different opinion. But I beg to remind him that, if my | ||
| 215 | +subjective deduction does not produce in his mind the conviction of | ||
| 216 | +its certitude at which I aimed, the objective deduction, with which | ||
| 217 | +alone the present work is properly concerned, is in every respect | ||
| 218 | +satisfactory. | ||
| 219 | + | ||
| 220 | + |
tests/document/saveMetadata.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +require_once("../../config/dmsDefaults.php"); | ||
| 4 | +require_once(KT_LIB_DIR . '/documentmanagement/documentutil.inc.php'); | ||
| 5 | +require_once(KT_LIB_DIR . '/filelike/fsfilelike.inc.php'); | ||
| 6 | + | ||
| 7 | +$oDocument =& Document::get(207); | ||
| 8 | +if (PEAR::isError($oDocument)) { | ||
| 9 | + print "FAILURE\n"; | ||
| 10 | + var_dump($oDocument); | ||
| 11 | +} | ||
| 12 | + | ||
| 13 | +$res = KTDocumentUtil::saveMetadata($oDocument, array()); | ||
| 14 | +if (PEAR::isError($res)) { | ||
| 15 | + print "FAILURE\n"; | ||
| 16 | + var_dump($res); | ||
| 17 | + exit(0); | ||
| 18 | +} | ||
| 19 | +// saveMetadata can update status id | ||
| 20 | +$oDocument->update(); | ||
| 21 | + | ||
| 22 | +if (file_exists($sFilename)) { | ||
| 23 | + unlink($sFilename); | ||
| 24 | +} | ||
| 25 | + | ||
| 26 | +?> |
tests/document/storeContents.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +require_once("../../config/dmsDefaults.php"); | ||
| 4 | +require_once(KT_LIB_DIR . '/documentmanagement/documentutil.inc.php'); | ||
| 5 | +require_once(KT_LIB_DIR . '/filelike/fsfilelike.inc.php'); | ||
| 6 | + | ||
| 7 | +$sLocalname = KT_DIR . "/tests/document/dataset1/critique-of-pure-reason.txt"; | ||
| 8 | +$sFilename = tempnam("/tmp", "kt_tests_document_add"); | ||
| 9 | +copy($sLocalname, $sFilename); | ||
| 10 | + | ||
| 11 | +$oDocument =& Document::get(207); | ||
| 12 | +if (PEAR::isError($oDocument)) { | ||
| 13 | + print "FAILURE\n"; | ||
| 14 | + var_dump($oDocument); | ||
| 15 | +} | ||
| 16 | + | ||
| 17 | +$res = KTDocumentUtil::storeContents($oDocument, new KTFSFileLike($sFilename)); | ||
| 18 | +if (PEAR::isError($res)) { | ||
| 19 | + print "FAILURE\n"; | ||
| 20 | + var_dump($res); | ||
| 21 | + exit(0); | ||
| 22 | +} | ||
| 23 | +// storeContents can update storage_path and also status id | ||
| 24 | +$oDocument->update(); | ||
| 25 | + | ||
| 26 | +if (file_exists($sFilename)) { | ||
| 27 | + unlink($sFilename); | ||
| 28 | +} | ||
| 29 | + | ||
| 30 | +?> |