Commit db75acba345f4378d9c4ccd986bccf3278e3c720
1 parent
25929c26
Tests for KTZipImportStorage
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3629 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
6 changed files
with
141 additions
and
0 deletions
tests/import/zipimport/bulktest.php
0 → 100644
| 1 | +<?php | |
| 2 | + | |
| 3 | +require_once("../../../config/dmsDefaults.php"); | |
| 4 | +require_once(KT_LIB_DIR . '/import/bulkimport.inc.php'); | |
| 5 | +require_once(KT_LIB_DIR . '/foldermanagement/folderutil.inc.php'); | |
| 6 | +require_once(KT_LIB_DIR . '/foldermanagement/Folder.inc'); | |
| 7 | +require_once(KT_LIB_DIR . '/users/User.inc'); | |
| 8 | +require_once(KT_LIB_DIR . '/import/zipimportstorage.inc.php'); | |
| 9 | + | |
| 10 | +$fs =& new KTZipImportStorage(KT_DIR . "/tests/import/dataset2/dataset2.zip"); | |
| 11 | + | |
| 12 | +$oParentFolder =& Folder::get(1); | |
| 13 | +$oFolder =& Folder::get(3); // KTFolderUtil::_add($oParentFolder, "bulktestfolder", User::get(1)); | |
| 14 | +$oUser =& User::get(1); | |
| 15 | + | |
| 16 | +$bm =& new KTBulkImportManager($oFolder, $fs, $oUser); | |
| 17 | + | |
| 18 | +$res = $bm->import(); | |
| 19 | +if (PEAR::isError($res)) { | |
| 20 | + print "FAILURE\n"; | |
| 21 | + var_dump($res); | |
| 22 | + exit(0); | |
| 23 | +} | |
| 24 | +var_dump($res); | ... | ... |
tests/import/zipimport/getDocumentInfo.php
0 → 100644
| 1 | +<?php | |
| 2 | + | |
| 3 | +require_once("../../../config/dmsDefaults.php"); | |
| 4 | +require_once(KT_LIB_DIR . '/import/zipimportstorage.inc.php'); | |
| 5 | + | |
| 6 | +$f = new KTZipImportStorage(KT_DIR . "/tests/import/dataset2/dataset2.zip"); | |
| 7 | +$f->init(); | |
| 8 | +$oInfo = $f->getDocumentInfo("a/b"); | |
| 9 | +$norm = file_get_contents(KT_DIR . '/tests/import/dataset1/a/b'); | |
| 10 | + | |
| 11 | +$gFilename = $oInfo->getFilename(); | |
| 12 | +if ($gFilename !== "b") { | |
| 13 | + print "FAILURE\n"; | |
| 14 | + print "Filename should have been: b\n"; | |
| 15 | + print "Filename was: " . $gFilename . "\n"; | |
| 16 | + exit(0); | |
| 17 | +} | |
| 18 | + | |
| 19 | +$oFile =& $oInfo->aVersions[0]; | |
| 20 | +$gData = $oFile->get_contents(); | |
| 21 | + | |
| 22 | +if ($norm !== $gData) { | |
| 23 | + print "FAILURE\n"; | |
| 24 | + print "Data doesn't match\n"; | |
| 25 | + exit(0); | |
| 26 | +} | |
| 27 | +$f->cleanup(); | |
| 28 | + | |
| 29 | +print "SUCCESS\n"; | ... | ... |
tests/import/zipimport/listDocumentsRoot.php
0 → 100644
| 1 | +<?php | |
| 2 | + | |
| 3 | +require_once("../../../config/dmsDefaults.php"); | |
| 4 | +require_once(KT_LIB_DIR . '/import/zipimportstorage.inc.php'); | |
| 5 | + | |
| 6 | +$f = new KTZipImportStorage(KT_DIR . "/tests/import/dataset2/dataset2.zip"); | |
| 7 | +$f->init(); | |
| 8 | + | |
| 9 | +$rootFiles = array("c"); | |
| 10 | + | |
| 11 | +if ($f->listDocuments("/") !== $rootFiles) { | |
| 12 | + print "Root file listing failure\n"; | |
| 13 | + print "Should be:\n"; | |
| 14 | + var_dump($rootFiles); | |
| 15 | + print "Got:\n"; | |
| 16 | + var_dump($f->listDocuments("/")); | |
| 17 | + $f->cleanup(); | |
| 18 | + exit(0); | |
| 19 | +} | |
| 20 | + | |
| 21 | +$f->cleanup(); | |
| 22 | + | |
| 23 | +print "SUCCESS\n"; | ... | ... |
tests/import/zipimport/listDocumentsSubdir.php
0 → 100644
| 1 | +<?php | |
| 2 | + | |
| 3 | +require_once("../../../config/dmsDefaults.php"); | |
| 4 | +require_once(KT_LIB_DIR . '/import/zipimportstorage.inc.php'); | |
| 5 | + | |
| 6 | +$f = new KTZipImportStorage(KT_DIR . "/tests/import/dataset2/dataset2.zip"); | |
| 7 | +$f->init(); | |
| 8 | + | |
| 9 | +$afiles = array("a/b"); | |
| 10 | + | |
| 11 | +if ($f->listDocuments("a") !== $afiles) { | |
| 12 | + print "Subdir (a) file listing failure\n"; | |
| 13 | + print "Should be:\n"; | |
| 14 | + var_dump($afiles); | |
| 15 | + print "Got:\n"; | |
| 16 | + var_dump($f->listDocuments("a")); | |
| 17 | + exit(0); | |
| 18 | +} | |
| 19 | +$f->cleanup(); | |
| 20 | + | |
| 21 | +print "SUCCESS\n"; | ... | ... |
tests/import/zipimport/listFoldersRoot.php
0 → 100644
| 1 | +<?php | |
| 2 | + | |
| 3 | +require_once("../../../config/dmsDefaults.php"); | |
| 4 | +require_once(KT_LIB_DIR . '/import/zipimportstorage.inc.php'); | |
| 5 | + | |
| 6 | +$f = new KTZipImportStorage(KT_DIR . "/tests/import/dataset2/dataset2.zip"); | |
| 7 | +$f->init(); | |
| 8 | + | |
| 9 | +$rootFolders = array("a"); | |
| 10 | + | |
| 11 | +if ($f->listFolders("/") !== $rootFolders) { | |
| 12 | + print "Root folder listing failure\n"; | |
| 13 | + print "Should be:\n"; | |
| 14 | + var_dump($rootFolders); | |
| 15 | + print "Got:\n"; | |
| 16 | + var_dump($f->listFolders("/")); | |
| 17 | + $f->cleanup(); | |
| 18 | + exit(0); | |
| 19 | +} | |
| 20 | + | |
| 21 | +$f->cleanup(); | |
| 22 | +print "SUCCESS\n"; | ... | ... |
tests/import/zipimport/listFoldersSubdir.php
0 → 100644
| 1 | +<?php | |
| 2 | + | |
| 3 | +require_once("../../../config/dmsDefaults.php"); | |
| 4 | +require_once(KT_LIB_DIR . '/import/zipimportstorage.inc.php'); | |
| 5 | + | |
| 6 | +$f = new KTZipImportStorage(KT_DIR . "/tests/import/dataset2/dataset2.zip"); | |
| 7 | +$f->init(); | |
| 8 | + | |
| 9 | +$afolders = array("a/d"); | |
| 10 | + | |
| 11 | +if ($f->listFolders("a") !== $afolders) { | |
| 12 | + print "Subdir (a) folder listing failure\n"; | |
| 13 | + print "Should be:\n"; | |
| 14 | + var_dump($afolders); | |
| 15 | + print "Got:\n"; | |
| 16 | + var_dump($f->listFolders("a")); | |
| 17 | + $f->cleanup(); | |
| 18 | + exit(0); | |
| 19 | +} | |
| 20 | + | |
| 21 | +$f->cleanup(); | |
| 22 | +print "SUCCESS\n"; | ... | ... |