Commit 9af024e03bd7b3e9cbf8200e3456d863fbb25125
Merge branch 'edge' of git@github.com:ktgit/knowledgetree into edge
Showing
12 changed files
with
700 additions
and
139 deletions
bin/upgrade/pear-upgrade.bat deleted
| 1 | - | |
| 2 | -; TEST ALL PEAR LIBRARIES BEFORE UPGRADING INTO RELEASE | |
| 3 | - | |
| 4 | -PATH=%PATH%;c:\php5\PEAR | |
| 5 | - | |
| 6 | -pear channel-update pear.php.net | |
| 7 | -pear config-set php_dir "C:\kt\kt.trunk\thirdparty\pear" | |
| 8 | - | |
| 9 | -pear config-set preferred_state stable | |
| 10 | - | |
| 11 | -pear upgrade --alldeps PEAR | |
| 12 | -pear upgrade --alldeps Cache_Lite | |
| 13 | -pear upgrade --alldeps Config | |
| 14 | -pear upgrade --alldeps DB | |
| 15 | -pear upgrade --alldeps File | |
| 16 | - | |
| 17 | -;pear upgrade --alldeps MDB2#mysql | |
| 18 | - | |
| 19 | -pear upgrade --alldeps Log | |
| 20 | -pear upgrade --alldeps PHP_Compat | |
| 21 | - | |
| 22 | -pear config-set preferred_state beta | |
| 23 | -pear upgrade --alldeps File_Gettext | |
| 24 | -pear upgrade --alldeps Net_LDAP | |
| 25 | -pear upgrade --alldeps SOAP | |
| 26 | -pear config-set preferred_state stable | |
| 27 | - |
bin/upgrade/pear-upgrade.sh deleted
| 1 | -#!/bin/bash | |
| 2 | - | |
| 3 | -# | |
| 4 | -# This script will upgrade all the pear components specific to knowledgetree | |
| 5 | -# | |
| 6 | - | |
| 7 | -#KTDIR="/var/www/knowledgetree" | |
| 8 | -KTDIR="$1"; | |
| 9 | -TMPDIR="$KTDIR/var/pear" | |
| 10 | - | |
| 11 | -if [ "$KTDIR" == "" ]; then | |
| 12 | - echo "Usage: $0 path/to/knowledgetree/directory"; | |
| 13 | - echo "e.g. $0 /var/www/knowledgetree"; | |
| 14 | - exit; | |
| 15 | -fi | |
| 16 | - | |
| 17 | -if [ ! -x "$TMPDIR" ]; then | |
| 18 | - mkdir -p "$TMPDIR" | |
| 19 | -fi | |
| 20 | - | |
| 21 | -if [ ! -x "$(which pear)" ]; then | |
| 22 | - echo "pear is not installed. please install pear before using this script."; | |
| 23 | - exit; | |
| 24 | -fi | |
| 25 | - | |
| 26 | -# Installing latest pear packages into tmp directory | |
| 27 | -pear config-set php_dir "$TMPDIR" | |
| 28 | -pear channel-update pear.php.net | |
| 29 | -pear config-set preferred_state stable | |
| 30 | -pear install --alldeps PEAR | |
| 31 | -pear install --alldeps Cache_Lite | |
| 32 | -pear install --alldeps Config | |
| 33 | -pear install --alldeps DB | |
| 34 | -pear install --alldeps File | |
| 35 | -pear install --alldeps MDB2#mysql | |
| 36 | -pear install --alldeps Log | |
| 37 | -pear install --alldeps PHP_Compat | |
| 38 | -pear install --alldeps Services_JSON | |
| 39 | -pear install --alldeps MIME_Type | |
| 40 | -pear config-set preferred_state beta | |
| 41 | -pear install --alldeps File_Gettext | |
| 42 | -pear install --alldeps Net_LDAP | |
| 43 | -pear install --alldeps SOAP | |
| 44 | -pear config-set preferred_state stable | |
| 45 | - | |
| 46 | -# Backing up the current pear directory | |
| 47 | -tar -czvf "$TMPDIR/pear_backup_$(date +%Y%m%d).tgz" "$KTDIR/thirdparty/pear" | |
| 48 | - | |
| 49 | -# | |
| 50 | -# The following section was created via an ls in the current knowledgetree | |
| 51 | -# pear directory for version 3.7.0.3 | |
| 52 | -# | |
| 53 | -# It contains the accurate/compressed list of pear packages known to be currently | |
| 54 | -# needed by knowledgetree. If any new package is implemented it should be added | |
| 55 | -# to this list to stay in the upgrade path. | |
| 56 | -# | |
| 57 | - | |
| 58 | -cp -frv "$TMPDIR/Config.php" "$KTDIR/thirdparty/pear/" | |
| 59 | -cp -frv "$TMPDIR/Console" "$KTDIR/thirdparty/pear/" | |
| 60 | -cp -frv "$TMPDIR/DB" "$KTDIR/thirdparty/pear/" | |
| 61 | -cp -frv "$TMPDIR/DB.php" "$KTDIR/thirdparty/pear/" | |
| 62 | -cp -frv "$TMPDIR/File" "$KTDIR/thirdparty/pear/" | |
| 63 | -cp -frv "$TMPDIR/GraphViz.php" "$KTDIR/thirdparty/pear/" | |
| 64 | -cp -frv "$TMPDIR/HTTP" "$KTDIR/thirdparty/pear/" | |
| 65 | -cp -frv "$TMPDIR/HTTP.php" "$KTDIR/thirdparty/pear/" | |
| 66 | -cp -frv "$TMPDIR/JSON.php" "$KTDIR/thirdparty/pear/" | |
| 67 | -cp -frv "$TMPDIR/Log" "$KTDIR/thirdparty/pear/" | |
| 68 | -cp -frv "$TMPDIR/Log.php" "$KTDIR/thirdparty/pear/" | |
| 69 | -cp -frv "$TMPDIR/MIME" "$KTDIR/thirdparty/pear/" | |
| 70 | -cp -frv "$TMPDIR/Net" "$KTDIR/thirdparty/pear/" | |
| 71 | -cp -frv "$TMPDIR/PEAR.php" "$KTDIR/thirdparty/pear/" | |
| 72 | -cp -frv "$TMPDIR/PHP" "$KTDIR/thirdparty/pear/" | |
| 73 | -cp -frv "$TMPDIR/SOAP" "$KTDIR/thirdparty/pear/" | |
| 74 | -cp -frv "$TMPDIR/System.php" "$KTDIR/thirdparty/pear/" |
ktapi/KTAPIFolder.inc.php
| ... | ... | @@ -291,7 +291,7 @@ class KTAPI_Folder extends KTAPI_FolderItem |
| 291 | 291 | * @param int $folderid |
| 292 | 292 | * @return KTAPI_Folder |
| 293 | 293 | */ |
| 294 | - function _get_folder_by_name($ktapi, $foldername, $folderid) | |
| 294 | + function _get_folder_by_name($ktapi, $foldername, $parentId) | |
| 295 | 295 | { |
| 296 | 296 | $foldername=trim($foldername); |
| 297 | 297 | if (empty($foldername)) |
| ... | ... | @@ -310,8 +310,8 @@ class KTAPI_Folder extends KTAPI_FolderItem |
| 310 | 310 | $foldername = KTUtil::replaceInvalidCharacters($foldername); |
| 311 | 311 | $foldername = sanitizeForSQL($foldername); |
| 312 | 312 | $sql = "SELECT id FROM folders WHERE |
| 313 | - (name='$foldername' and parent_id=$folderid) OR | |
| 314 | - (name='$foldername' and parent_id is null and $folderid=1)"; | |
| 313 | + (name='$foldername' and parent_id=$parentId) OR | |
| 314 | + (name='$foldername' and parent_id is null and $parentId=1)"; | |
| 315 | 315 | $row = DBUtil::getOneResult($sql); |
| 316 | 316 | if (is_null($row) || PEAR::isError($row)) |
| 317 | 317 | { |
| ... | ... | @@ -377,7 +377,8 @@ class KTAPI_Folder extends KTAPI_FolderItem |
| 377 | 377 | |
| 378 | 378 | if (!empty($foldername) && ($foldername != '.')) |
| 379 | 379 | { |
| 380 | - $ktapi_folder = $this->get_folder_by_name($foldername); | |
| 380 | + // TODO confirm that this addition of the parent folder id as second parameter is correct and necessary | |
| 381 | + $ktapi_folder = $this->get_folder_by_name($foldername, $this->folderid); | |
| 381 | 382 | } |
| 382 | 383 | |
| 383 | 384 | $currentFolderName = $this->get_folder_name(); |
| ... | ... | @@ -391,7 +392,8 @@ class KTAPI_Folder extends KTAPI_FolderItem |
| 391 | 392 | else |
| 392 | 393 | { |
| 393 | 394 | $foldername = substr($foldername, strlen($currentFolderName)+1); |
| 394 | - $ktapi_folder = $this->get_folder_by_name($foldername); | |
| 395 | + // TODO confirm that this addition of the parent folder id as second parameter is correct and necessary | |
| 396 | + $ktapi_folder = $this->get_folder_by_name($foldername, $this->folderid); | |
| 395 | 397 | } |
| 396 | 398 | } |
| 397 | 399 | ... | ... |
ktapi/ktapi.inc.php
| ... | ... | @@ -842,11 +842,12 @@ class KTAPI |
| 842 | 842 | * @author KnowledgeTree Team |
| 843 | 843 | * @access public |
| 844 | 844 | * @param string $foldername The folder name |
| 845 | + * @param int $parent_id The folder in which to search for the requested child folder | |
| 845 | 846 | * @return object $folder The KTAPI_Folder object |
| 846 | 847 | */ |
| 847 | - public function &get_folder_by_name($foldername, $parentId = 1) | |
| 848 | + public function &get_folder_by_name($foldername, $parent_id = 1) | |
| 848 | 849 | { |
| 849 | - $folder = KTAPI_Folder::_get_folder_by_name($this, $foldername, $parentId); | |
| 850 | + $folder = KTAPI_Folder::_get_folder_by_name($this, $foldername, $parent_id); | |
| 850 | 851 | return $folder; |
| 851 | 852 | } |
| 852 | 853 | |
| ... | ... | @@ -2027,14 +2028,14 @@ class KTAPI |
| 2027 | 2028 | function get_folder_shortcuts($folder_id) |
| 2028 | 2029 | { |
| 2029 | 2030 | $folder = $this->get_folder_by_id($folder_id); |
| 2030 | - if(PEAR::isError($folder)){ | |
| 2031 | + if(PEAR::isError($folder)) { | |
| 2031 | 2032 | $response['status_code'] = 1; |
| 2032 | 2033 | $response['message']= $folder->getMessage(); |
| 2033 | 2034 | return $response; |
| 2034 | 2035 | } |
| 2035 | 2036 | |
| 2036 | 2037 | $shortcuts = $folder->get_shortcuts(); |
| 2037 | - if(PEAR::isError($shortcuts)){ | |
| 2038 | + if(PEAR::isError($shortcuts)) { | |
| 2038 | 2039 | $response['status_code'] = 1; |
| 2039 | 2040 | $response['message']= $shortcuts->getMessage(); |
| 2040 | 2041 | return $response; |
| ... | ... | @@ -2054,10 +2055,10 @@ class KTAPI |
| 2054 | 2055 | * @param string $folder_name The name of the folder |
| 2055 | 2056 | * @return array Response 'results' contains kt_folder_detail | 'message' contains error message on failure |
| 2056 | 2057 | */ |
| 2057 | - function get_folder_detail_by_name($folder_name) | |
| 2058 | + function get_folder_detail_by_name($folder_name, $parent_id = 1) | |
| 2058 | 2059 | { |
| 2059 | - $folder = &$this->get_folder_by_name($folder_name); | |
| 2060 | - if(PEAR::isError($folder)){ | |
| 2060 | + $folder = &$this->get_folder_by_name($folder_name, $parent_id); | |
| 2061 | + if(PEAR::isError($folder)) { | |
| 2061 | 2062 | $response['status_code'] = 1; |
| 2062 | 2063 | $response['message']= $folder->getMessage(); |
| 2063 | 2064 | return $response; |
| ... | ... | @@ -2343,7 +2344,7 @@ class KTAPI |
| 2343 | 2344 | $sourceName = $src_folder->get_folder_name(); |
| 2344 | 2345 | $targetPath = $tgt_folder->get_full_path(); |
| 2345 | 2346 | |
| 2346 | - $response['results'] = $this->get_folder_detail_by_name($targetPath . '/' . $sourceName); | |
| 2347 | + $response['results'] = $this->get_folder_detail_by_name($targetPath . '/' . $sourceName, $source_id); | |
| 2347 | 2348 | return $response; |
| 2348 | 2349 | } |
| 2349 | 2350 | ... | ... |
ktwebservice/webservice.php
| ... | ... | @@ -769,14 +769,20 @@ class KTWebService |
| 769 | 769 | |
| 770 | 770 | // get_folder_detail_by_name |
| 771 | 771 | $this->__dispatch_map['get_folder_detail_by_name'] = |
| 772 | - array('in' => array('session_id' => 'string', 'folder_name' => 'string' ), | |
| 772 | + array('in' => array('session_id' => 'string', 'folder_name' => 'string', 'parent_id' => 'int' ), | |
| 773 | 773 | 'out' => array('return' => "{urn:$this->namespace}kt_folder_detail"), |
| 774 | 774 | ); |
| 775 | 775 | |
| 776 | + /* If this is now the same as version 2 for this function, we don't need this. | |
| 777 | + * | |
| 776 | 778 | if ($this->version >=3) |
| 777 | 779 | { |
| 780 | + // was | |
| 778 | 781 | $this->__dispatch_map['get_folder_detail_by_name']['in'] = array('session_id' => 'string', 'folder_id' => 'int', 'create'=>'boolean' ); |
| 782 | + // now | |
| 783 | + $this->__dispatch_map['get_folder_detail_by_name']['in'] = array('session_id' => 'string', 'folder_id' => 'int', 'parent_id'=>'int' ); | |
| 779 | 784 | } |
| 785 | + */ | |
| 780 | 786 | |
| 781 | 787 | // get_folder_contents |
| 782 | 788 | $this->__dispatch_map['get_folder_contents'] = |
| ... | ... | @@ -1507,22 +1513,23 @@ class KTWebService |
| 1507 | 1513 | * |
| 1508 | 1514 | * @param string $session_id |
| 1509 | 1515 | * @param string $folder_name |
| 1516 | + * @param integer $parent_id The parent folder in which to look for the named folder | |
| 1510 | 1517 | * @return kt_folder_detail. status_code can be KTWS_ERR_INVALID_SESSION, KTWS_ERR_INVALID_FOLDER, or KTWS_SUCCESS. |
| 1511 | 1518 | */ |
| 1512 | - function get_folder_detail_by_name($session_id, $folder_name) | |
| 1519 | + function get_folder_detail_by_name($session_id, $folder_name, $parent_id = 1) | |
| 1513 | 1520 | { |
| 1514 | - $this->debug("get_folder_detail_by_name('$session_id','$folder_name')"); | |
| 1521 | + $this->debug("get_folder_detail_by_name('$session_id','$folder_name','$parent_id')"); | |
| 1515 | 1522 | $kt = &$this->get_ktapi($session_id); |
| 1516 | 1523 | if (is_array($kt)) |
| 1517 | 1524 | { |
| 1518 | 1525 | return new SOAP_Value('return',"{urn:$this->namespace}kt_folder_detail", $kt); |
| 1519 | 1526 | } |
| 1520 | 1527 | |
| 1521 | - $folder = &$kt->get_folder_by_name($folder_name); | |
| 1528 | + $folder = &$kt->get_folder_by_name($folder_name, $parent_id); | |
| 1522 | 1529 | if (PEAR::isError($folder)) |
| 1523 | 1530 | { |
| 1524 | 1531 | $response = KTWebService::_status(KTWS_ERR_INVALID_FOLDER,$folder); |
| 1525 | - $this->debug("get_folder_detail_by_name - cannot get folder $folder_name - " . $folder->getMessage(), $session_id); | |
| 1532 | + $this->debug("get_folder_detail_by_name - cannot get folder $folder_name (looking in folder $parent_id) - " . $folder->getMessage(), $session_id); | |
| 1526 | 1533 | return new SOAP_Value('return',"{urn:$this->namespace}kt_folder_detail", $response); |
| 1527 | 1534 | } |
| 1528 | 1535 | |
| ... | ... | @@ -1883,11 +1890,10 @@ class KTWebService |
| 1883 | 1890 | |
| 1884 | 1891 | if ($this->version >=2) |
| 1885 | 1892 | { |
| 1886 | - | |
| 1887 | 1893 | $sourceName = $src_folder->get_folder_name(); |
| 1888 | 1894 | $targetPath = $tgt_folder->get_full_path(); |
| 1889 | 1895 | |
| 1890 | - $response = $this->get_folder_detail_by_name($session_id, $targetPath . '/' . $sourceName); | |
| 1896 | + $response = $this->get_folder_detail_by_name($session_id, $targetPath . '/' . $sourceName, $source_id); | |
| 1891 | 1897 | |
| 1892 | 1898 | return $response; |
| 1893 | 1899 | } | ... | ... |
plugins/ktcore/KTBulkActions.php
| ... | ... | @@ -90,13 +90,10 @@ class KTBulkDeleteAction extends KTBulkAction { |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | // If all documents at the current level may be deleted, we can continue |
| 93 | - // Get any existing subfolders | |
| 94 | - $sWhereClause = "parent_folder_ids = '{$sFolderId}' OR | |
| 95 | - parent_folder_ids LIKE '{$sFolderId},%' OR | |
| 96 | - parent_folder_ids LIKE '%,{$sFolderId},%' OR | |
| 97 | - parent_folder_ids LIKE '%,{$sFolderId}'"; | |
| 93 | + // Get any existing subfolders - but ONLY on the current level, or we will be checking subfolders more than once! | |
| 94 | + $sWhereClause = "parent_id = '{$sFolderId}'"; | |
| 98 | 95 | $aChildFolders = $this->oFolder->getList($sWhereClause); |
| 99 | - | |
| 96 | + | |
| 100 | 97 | // Loop through subfolders and check each in the same way as the parent |
| 101 | 98 | if(!empty($aChildFolders)){ |
| 102 | 99 | foreach($aChildFolders as $oChild){ | ... | ... |
plugins/ktcore/admin/manageBranding.php
| ... | ... | @@ -47,7 +47,6 @@ require_once(KT_LIB_DIR . "/validation/dispatchervalidation.inc.php"); |
| 47 | 47 | require_once(KT_LIB_DIR . "/metadata/fieldsetregistry.inc.php"); |
| 48 | 48 | require_once(KT_LIB_DIR . "/validation/validatorfactory.inc.php"); |
| 49 | 49 | |
| 50 | - | |
| 51 | 50 | class ManageBrandDispatcher extends KTAdminDispatcher { |
| 52 | 51 | |
| 53 | 52 | private $maxLogoWidth = 313; |
| ... | ... | @@ -61,7 +60,6 @@ class ManageBrandDispatcher extends KTAdminDispatcher { |
| 61 | 60 | } |
| 62 | 61 | |
| 63 | 62 | function do_main() { |
| 64 | - | |
| 65 | 63 | $oForms[] = $this->getLogoDetailsForm(); |
| 66 | 64 | $oForms[] = $this->getUploadLogoForm(); |
| 67 | 65 | |
| ... | ... | @@ -98,10 +96,11 @@ class ManageBrandDispatcher extends KTAdminDispatcher { |
| 98 | 96 | 'encoding' => 'multipart/form-data', |
| 99 | 97 | 'context' => &$this, |
| 100 | 98 | 'extraargs' => $this->meldPersistQuery("","",true), |
| 101 | - 'description' => _kt('You can set the branding details.') | |
| 99 | + 'description' => _kt('You can set the branding details.') | |
| 102 | 100 | )); |
| 103 | 101 | |
| 104 | 102 | $oWF =& KTWidgetFactory::getSingleton(); |
| 103 | + $oVF =& KTValidatorFactory::getSingleton(); | |
| 105 | 104 | |
| 106 | 105 | $widgets = array(); |
| 107 | 106 | $validators = array(); |
| ... | ... | @@ -126,7 +125,14 @@ class ManageBrandDispatcher extends KTAdminDispatcher { |
| 126 | 125 | 'name' => 'logo_url', |
| 127 | 126 | 'id' => 'file', |
| 128 | 127 | 'value' => $logoUrl, |
| 129 | - 'description' => _kt("This is the website address you will be redirected to after clicking the logo"), | |
| 128 | + 'description' => _kt("This is the website address you will be redirected to after clicking the logo. The url should include the protocol e.g. http://www.knowledgetree.com . If no protocol is given the url is treated as a relative link."), | |
| 129 | + )); | |
| 130 | + | |
| 131 | + | |
| 132 | + // Adding the url widget | |
| 133 | + $validators[] = $oVF->get('ktcore.widgets.string', array( | |
| 134 | + 'test' => 'logo_url', | |
| 135 | + 'output' => 'logo_url', | |
| 130 | 136 | )); |
| 131 | 137 | |
| 132 | 138 | $oForm->setWidgets($widgets); |
| ... | ... | @@ -430,9 +436,6 @@ class ManageBrandDispatcher extends KTAdminDispatcher { |
| 430 | 436 | |
| 431 | 437 | return $oForm; |
| 432 | 438 | } |
| 433 | - | |
| 434 | - | |
| 435 | - | |
| 436 | 439 | |
| 437 | 440 | /* |
| 438 | 441 | * Action responsible for setting the logo details |
| ... | ... | @@ -446,6 +449,12 @@ class ManageBrandDispatcher extends KTAdminDispatcher { |
| 446 | 449 | $logoUrl = $_REQUEST['data']['logo_url']; |
| 447 | 450 | $logoTitle = $_REQUEST['data']['logo_title']; |
| 448 | 451 | |
| 452 | + $aOptions = array('redirect_to' => 'main'); | |
| 453 | + | |
| 454 | + if ($logoTitle != '') { | |
| 455 | + $this->oValidator->validateIllegalCharacters($logoTitle, $aOptions); | |
| 456 | + } | |
| 457 | + | |
| 449 | 458 | if ($config->set('ui/companyLogoUrl', $logoUrl) && $config->set('ui/companyLogoTitle', $logoTitle)) { |
| 450 | 459 | $this->successRedirectTo('main', _kt('Logo fields have been successfully updated.')); |
| 451 | 460 | } else { |
| ... | ... | @@ -454,8 +463,6 @@ class ManageBrandDispatcher extends KTAdminDispatcher { |
| 454 | 463 | |
| 455 | 464 | } |
| 456 | 465 | |
| 457 | - | |
| 458 | - | |
| 459 | 466 | /* |
| 460 | 467 | * Action responsible for uploading the logo |
| 461 | 468 | * |
| ... | ... | @@ -597,7 +604,6 @@ class ManageBrandDispatcher extends KTAdminDispatcher { |
| 597 | 604 | |
| 598 | 605 | } |
| 599 | 606 | |
| 600 | - | |
| 601 | 607 | /** |
| 602 | 608 | * Returns the MIME of the filename, deducted from its extension |
| 603 | 609 | * If the extension is unknown, returns "image/jpeg" |
| ... | ... | @@ -674,7 +680,6 @@ class ManageBrandDispatcher extends KTAdminDispatcher { |
| 674 | 680 | |
| 675 | 681 | return FALSE; |
| 676 | 682 | } |
| 677 | - | |
| 678 | 683 | |
| 679 | 684 | /* |
| 680 | 685 | * This method uses the GD library to scale an image. | ... | ... |
sql/mysql/install/data.sql
| ... | ... | @@ -1781,7 +1781,8 @@ INSERT INTO `upgrades` VALUES |
| 1781 | 1781 | (235,'sql*3.7.0.3*0*3.7.0.3/clienttools_config.sql','Database upgrade to version 3.7.0.3: Clienttools Config','2009-12-10 00:00:00',1,'upgrade*3.7.0.3*99*upgrade3.7.0.3'), |
| 1782 | 1782 | (236,'sql*3.7.0.3*0*3.7.0.3/uploaded_files.sql','Database upgrade to version 3.7.0.3: Uploaded Files','2009-12-10 00:00:00',1,'upgrade*3.7.0.3*99*upgrade3.7.0.3'), |
| 1783 | 1783 | (237,'sql*3.7.0.3*0*3.7.0.3/active_sessions_ip.sql','Database upgrade to version 3.7.0.3: Active Sessions Ip','2009-12-10 00:00:00',1,'upgrade*3.7.0.3*99*upgrade3.7.0.3'), |
| 1784 | -(238,'upgrade*3.7.0.3*99*upgrade3.7.0.3','Upgrade from version 3.7.0.2 to 3.7.0.3','2009-12-14 00:00:00',1,'upgrade*3.7.0.3*99*upgrade3.7.0.3'); | |
| 1784 | +(238,'sql*3.7.0.3*0*3.7.0.3/download_queue_zip.sql','Database upgrade to version 3.7.0.3: Download Queue Zip','2009-12-10 00:00:00',1,'upgrade*3.7.0.3*99*upgrade3.7.0.3'), | |
| 1785 | +(239,'upgrade*3.7.0.3*99*upgrade3.7.0.3','Upgrade from version 3.7.0.2 to 3.7.0.3','2009-12-14 00:00:00',1,'upgrade*3.7.0.3*99*upgrade3.7.0.3'); | |
| 1785 | 1786 | /*!40000 ALTER TABLE `upgrades` ENABLE KEYS */; |
| 1786 | 1787 | UNLOCK TABLES; |
| 1787 | 1788 | ... | ... |
tests/api/testApi.php
| ... | ... | @@ -295,6 +295,7 @@ class APITestCase extends KTUnitTestCase { |
| 295 | 295 | * This method tests the retrieval of a folder by name |
| 296 | 296 | * |
| 297 | 297 | */ |
| 298 | + /* replaced by the new function below | |
| 298 | 299 | public function testGetFolderByName() |
| 299 | 300 | { |
| 300 | 301 | $folder = $this->ktapi->get_folder_by_name('Root Folder'); |
| ... | ... | @@ -303,6 +304,7 @@ class APITestCase extends KTUnitTestCase { |
| 303 | 304 | $this->assertIsA($folder, 'KTAPI_Folder'); |
| 304 | 305 | $this->assertNoErrors(); |
| 305 | 306 | } |
| 307 | + */ | |
| 306 | 308 | |
| 307 | 309 | /** |
| 308 | 310 | * This method tests the retrieval of a document by it's id |
| ... | ... | @@ -607,6 +609,181 @@ class APITestCase extends KTUnitTestCase { |
| 607 | 609 | $detail2 = $this->ktapi->get_folder_detail($folder_id); |
| 608 | 610 | $this->assertNotEqual($detail2['status_code'], 0); |
| 609 | 611 | } |
| 612 | + | |
| 613 | + /** | |
| 614 | + * Tests finding of a folder or folder detail by name | |
| 615 | + * | |
| 616 | + * Runs the following sub-tests: | |
| 617 | + * | |
| 618 | + * . Root folder Folder by Name (root folder test) | |
| 619 | + * . Folder Detail by Name in root folder (no duplicate names) | |
| 620 | + * . Folder Detail by name in subfolder of root folder (no duplicate names) | |
| 621 | + * . Folder by Name in subfolder of root folder (no duplicate names) | |
| 622 | + * . Folder by Name in root folder (duplicate names) | |
| 623 | + * . Folder Detail by name in subfolder of root folder (duplicate names) | |
| 624 | + * . Folder by name in subfolder of root folder (duplicate names) | |
| 625 | + */ | |
| 626 | + public function testGetFolderByName() | |
| 627 | + { | |
| 628 | + // set up | |
| 629 | + $root_folder_id = array(); | |
| 630 | + $sub_folder_id = array(); | |
| 631 | + $folders[0][1] = 'Root Folder'; | |
| 632 | + | |
| 633 | + // Create a sub folder in the root folder | |
| 634 | + $parentId = 1; | |
| 635 | + $folderName = 'Test api sub-folder ONE'; | |
| 636 | + $result1 = $this->ktapi->create_folder($parentId, $folderName, KT_TEST_USER, KT_TEST_PASS, 'Testing API'); | |
| 637 | + $root_folder_id[] = $result1['results']['id']; | |
| 638 | + $folders[$parentId][$result1['results']['id']] = $folderName; | |
| 639 | + $this->assertEqual($result1['status_code'], 0); | |
| 640 | + | |
| 641 | + // Create a second sub folder in the root folder | |
| 642 | + $parentId = 1; | |
| 643 | + $folderName = 'Test api sub-folder TWO'; | |
| 644 | + $result1 = $this->ktapi->create_folder($parentId, $folderName, KT_TEST_USER, KT_TEST_PASS, 'Testing API'); | |
| 645 | + $root_folder_id[] = $result1['results']['id']; | |
| 646 | + $folders[$parentId][$result1['results']['id']] = $folderName; | |
| 647 | + $this->assertEqual($result1['status_code'], 0); | |
| 648 | + | |
| 649 | + // Create a sub folder in the first sub folder | |
| 650 | + $parentId = $root_folder_id[0]; | |
| 651 | + $folderName = 'Test api sub-folder THREE'; | |
| 652 | + $result2 = $this->ktapi->create_folder($parentId, $folderName, KT_TEST_USER, KT_TEST_PASS, 'Testing API'); | |
| 653 | + $sub_folder_id[0][] = $result2['results']['id']; | |
| 654 | + $folders[$parentId][$result2['results']['id']] = $folderName; | |
| 655 | + $this->assertEqual($result2['status_code'], 0); | |
| 656 | + | |
| 657 | + // Create a sub folder within the first sub folder which shares a name with one of the root sub folders | |
| 658 | + $parentId = $sub_folder_id[0][0]; | |
| 659 | + $folderName = 'Test api sub-folder TWO'; | |
| 660 | + $result2 = $this->ktapi->create_folder($parentId, $folderName, KT_TEST_USER, KT_TEST_PASS, 'Testing API'); | |
| 661 | + $sub_folder_id[0][] = $result2['results']['id']; | |
| 662 | + $folders[$parentId][$result2['results']['id']] = $folderName; | |
| 663 | + $this->assertEqual($result2['status_code'], 0); | |
| 664 | + | |
| 665 | + // Create a second sub folder in the first sub folder | |
| 666 | + $parentId = $root_folder_id[0]; | |
| 667 | + $folderName = 'Test api sub-folder FOUR'; | |
| 668 | + $result2 = $this->ktapi->create_folder($parentId, $folderName, KT_TEST_USER, KT_TEST_PASS, 'Testing API'); | |
| 669 | + $sub_folder_id[0][] = $result2['results']['id']; | |
| 670 | + $folders[$parentId][$result2['results']['id']] = $folderName; | |
| 671 | + $this->assertEqual($result2['status_code'], 0); | |
| 672 | + | |
| 673 | + // Create a sub folder within the second sub folder | |
| 674 | + $parentId = $root_folder_id[1]; | |
| 675 | + $folderName = 'Test api sub-folder FIVE'; | |
| 676 | + $result2 = $this->ktapi->create_folder($parentId, $folderName, KT_TEST_USER, KT_TEST_PASS, 'Testing API'); | |
| 677 | + $sub_folder_id[1][] = $result2['results']['id']; | |
| 678 | + $folders[$parentId][$result2['results']['id']] = $folderName; | |
| 679 | + $this->assertEqual($result2['status_code'], 0); | |
| 680 | + | |
| 681 | + // Create a sub folder within the second sub folder which shares a name with a sub folder in the first sub folder | |
| 682 | + $parentId = $sub_folder_id[1][0]; | |
| 683 | + $folderName = 'Test api sub-folder THREE'; | |
| 684 | + $result2 = $this->ktapi->create_folder($parentId, $folderName, KT_TEST_USER, KT_TEST_PASS, 'Testing API'); | |
| 685 | + $sub_folder_id[1][] = $result2['results']['id']; | |
| 686 | + $folders[$parentId][$result2['results']['id']] = $folderName; | |
| 687 | + $this->assertEqual($result2['status_code'], 0); | |
| 688 | + | |
| 689 | + // NOTE default parent is 1, so does not need to be declared when searching the root folder, but we use it elsewhere | |
| 690 | + | |
| 691 | + // Fetching of root folder - this used to be in the other test | |
| 692 | + $parentId = 0; | |
| 693 | + $folderName = 'Root Folder'; | |
| 694 | + // no parent required | |
| 695 | + $folder = $this->ktapi->get_folder_by_name($folderName); | |
| 696 | + $this->assertNotNull($folder); | |
| 697 | + $this->assertIsA($folder, 'KTAPI_Folder'); | |
| 698 | + $this->assertNoErrors(); | |
| 699 | + // confirm folder id matches expected | |
| 700 | + if (is_a($folder, 'KTAPI_Folder')) { | |
| 701 | + $this->assertEqual($folders[$parentId][$folder->get_folderid()], $folderName); | |
| 702 | + } | |
| 703 | + | |
| 704 | + // Folder Detail by Name in root folder (no duplicate names) | |
| 705 | + $parentId = 1; | |
| 706 | + $folderName = 'Test api sub-folder ONE'; | |
| 707 | + // no parent required | |
| 708 | + $response = $this->ktapi->get_folder_detail_by_name($folderName); | |
| 709 | + $this->assertNotNull($response['results']); | |
| 710 | + $this->assertNoErrors(); | |
| 711 | + // confirm folder id matches expected | |
| 712 | + if (!empty($response)) { | |
| 713 | + $this->assertEqual($folders[$parentId][$response['results']['id']], $folderName); | |
| 714 | + } | |
| 715 | + | |
| 716 | + // Folder Detail by Name in sub folder of root folder (no duplicate names) | |
| 717 | + $parentId = $root_folder_id[0]; | |
| 718 | + $folderName = 'Test api sub-folder FOUR'; | |
| 719 | + // no parent required | |
| 720 | + $response = $this->ktapi->get_folder_detail_by_name($folderName, $parentId); | |
| 721 | + $this->assertNotNull($response['results']); | |
| 722 | + $this->assertNoErrors(); | |
| 723 | + // confirm folder id matches expected | |
| 724 | + if (!empty($response)) { | |
| 725 | + $this->assertEqual($folders[$parentId][$response['results']['id']], $folderName); | |
| 726 | + } | |
| 727 | + | |
| 728 | + // Folder by Name in subfolder of root folder (no duplicate names) | |
| 729 | + $parentId = $root_folder_id[0]; | |
| 730 | + $folderName = 'Test api sub-folder FOUR'; | |
| 731 | + $folder = $this->ktapi->get_folder_by_name($folderName, $parentId); | |
| 732 | + $this->assertNotNull($folder); | |
| 733 | + $this->assertIsA($folder, 'KTAPI_Folder'); | |
| 734 | + $this->assertNoErrors(); | |
| 735 | + // confirm folder id matches expected | |
| 736 | + if (is_a($folder, 'KTAPI_Folder')) { | |
| 737 | + $this->assertEqual($folders[$parentId][$folder->get_folderid()], $folderName); | |
| 738 | + } | |
| 739 | + | |
| 740 | + // Folder by Name in root folder (duplicate names) | |
| 741 | + $parentId = 1; | |
| 742 | + $folderName = 'Test api sub-folder TWO'; | |
| 743 | + // no parent required | |
| 744 | + $folder = $this->ktapi->get_folder_by_name($folderName); | |
| 745 | + $this->assertNotNull($folder); | |
| 746 | + $this->assertIsA($folder, 'KTAPI_Folder'); | |
| 747 | + $this->assertNoErrors(); | |
| 748 | + // confirm folder id matches expected | |
| 749 | + if (is_a($folder, 'KTAPI_Folder')) { | |
| 750 | + $this->assertEqual($folders[$parentId][$folder->get_folderid()], $folderName); | |
| 751 | + } | |
| 752 | + | |
| 753 | + // Folder Detail by Name in sub folder of root folder (duplicate names) | |
| 754 | + $parentId = $root_folder_id[0]; | |
| 755 | + $folderName = 'Test api sub-folder THREE'; | |
| 756 | + $response = $this->ktapi->get_folder_detail_by_name($folderName, $parentId); | |
| 757 | + $this->assertNotNull($response['results']); | |
| 758 | + $this->assertNoErrors(); | |
| 759 | + // confirm folder id matches expected | |
| 760 | + if (!empty($response)) { | |
| 761 | + $this->assertEqual($folders[$parentId][$response['results']['id']], $folderName); | |
| 762 | + } | |
| 763 | + | |
| 764 | + // Folder by Name in sub folder of sub folder (duplicate names) | |
| 765 | + $parentId = $sub_folder_id[0][0]; | |
| 766 | + $folderName = 'Test api sub-folder TWO'; | |
| 767 | + $folder = $this->ktapi->get_folder_by_name($folderName, $parentId); | |
| 768 | + $this->assertNotNull($folder); | |
| 769 | + $this->assertIsA($folder, 'KTAPI_Folder'); | |
| 770 | + $this->assertNoErrors(); | |
| 771 | + // confirm folder id matches expected | |
| 772 | + if (is_a($folder, 'KTAPI_Folder')) { | |
| 773 | + $this->assertEqual($folders[$parentId][$folder->get_folderid()], $folderName); | |
| 774 | + } | |
| 775 | + | |
| 776 | + // Clean up - delete all of the folders | |
| 777 | + foreach ($root_folder_id as $folder_id) { | |
| 778 | + $this->ktapi->delete_folder($folder_id, 'Testing API', KT_TEST_USER, KT_TEST_PASS); | |
| 779 | + } | |
| 780 | + | |
| 781 | + foreach ($sub_folder_id as $_folder_id_) { | |
| 782 | + foreach ($_folder_id_ as $folder_id) { | |
| 783 | + $this->ktapi->delete_folder($folder_id, 'Testing API', KT_TEST_USER, KT_TEST_PASS); | |
| 784 | + } | |
| 785 | + } | |
| 786 | + } | |
| 610 | 787 | |
| 611 | 788 | /** |
| 612 | 789 | * Helper function to create a document | ... | ... |
tests/runtests.php
| ... | ... | @@ -38,6 +38,10 @@ class UnitTests extends TestSuite { |
| 38 | 38 | // are not on, so if you have failures, check there first :) |
| 39 | 39 | $this->addFile('api/testElectronicSignatures.php'); |
| 40 | 40 | |
| 41 | + // Web Service tests | |
| 42 | + $this->addFile('webservices/testRest.php'); | |
| 43 | + $this->addFile('webservices/testSoap.php'); | |
| 44 | + | |
| 41 | 45 | // $this->addFile('SQLFile/test_sqlfile.php'); |
| 42 | 46 | // $this->addFile('cache/testCache.php'); |
| 43 | 47 | // $this->addFile('config/testConfig.php'); | ... | ... |
tests/webservices/testRest.php
| ... | ... | @@ -137,6 +137,210 @@ class RESTTestCase extends KTUnitTestCase { |
| 137 | 137 | $this->assertTrue(empty($response['results'])); |
| 138 | 138 | $this->assertTrue(!empty($response['message'])); |
| 139 | 139 | } |
| 140 | + | |
| 141 | + /** | |
| 142 | + * Tests finding of a folder or folder detail by name | |
| 143 | + * Runs the following sub-tests: | |
| 144 | + * . Root folder Folder by Name (root folder test) | |
| 145 | + * . Folder Detail by Name in root folder (no duplicate names) | |
| 146 | + * . Folder Detail by name in subfolder of root folder (no duplicate names) | |
| 147 | + * . Folder by Name in subfolder of root folder (no duplicate names) | |
| 148 | + * . Folder by Name in root folder (duplicate names) | |
| 149 | + * . Folder Detail by name in subfolder of root folder (duplicate names) | |
| 150 | + * . Folder by name in subfolder of root folder (duplicate names) | |
| 151 | + */ | |
| 152 | + public function testGetFolderByName() | |
| 153 | + { | |
| 154 | + // Login and authenticate | |
| 155 | + $url = $this->rootUrl.'method=login&password=admin&username=admin'; | |
| 156 | + $response = $this->call($url); | |
| 157 | + $response = $response['response']; | |
| 158 | + | |
| 159 | + $this->assertEqual($response['status_code'], 0); | |
| 160 | + $session_id = $response['results']; | |
| 161 | + | |
| 162 | + // set up | |
| 163 | + $root_folder_id = array(); | |
| 164 | + $sub_folder_id = array(); | |
| 165 | + $folders[0][1] = 'Root Folder'; | |
| 166 | + | |
| 167 | + // Create a sub folder in the root folder | |
| 168 | + $parentId = 1; | |
| 169 | + $folderName = 'Test api sub-folder ONE'; | |
| 170 | + $url = $this->rootUrl.'method=create_folder&session_id=' . $session_id . '&folder_id=' . $parentId . '&folder_name=' . urlencode($folderName); | |
| 171 | + $response = $this->call($url); | |
| 172 | + $response = $response['response']; | |
| 173 | + $root_folder_id[] = $response['results']['id']; | |
| 174 | + $folders[$parentId][$response['results']['id']] = $folderName; | |
| 175 | + $this->assertEqual($response['status_code'], 0); | |
| 176 | + | |
| 177 | + // Create a second sub folder in the root folder | |
| 178 | + $parentId = 1; | |
| 179 | + $folderName = 'Test api sub-folder TWO'; | |
| 180 | + $url = $this->rootUrl.'method=create_folder&session_id=' . $session_id . '&folder_id=' . $parentId . '&folder_name=' . urlencode($folderName); | |
| 181 | + $response = $this->call($url); | |
| 182 | + $response = $response['response']; | |
| 183 | + $root_folder_id[] = $response['results']['id']; | |
| 184 | + $folders[$parentId][$response['results']['id']] = $folderName; | |
| 185 | + $this->assertEqual($response['status_code'], 0); | |
| 186 | + | |
| 187 | + // Create a sub folder in the first sub folder | |
| 188 | + $parentId = $root_folder_id[0]; | |
| 189 | + $folderName = 'Test api sub-folder THREE'; | |
| 190 | + $url = $this->rootUrl.'method=create_folder&session_id=' . $session_id . '&folder_id=' . $parentId . '&folder_name=' . urlencode($folderName); | |
| 191 | + $response = $this->call($url); | |
| 192 | + $response = $response['response']; | |
| 193 | + $sub_folder_id[0][] = $response['results']['id']; | |
| 194 | + $folders[$parentId][$response['results']['id']] = $folderName; | |
| 195 | + $this->assertEqual($response['status_code'], 0); | |
| 196 | + | |
| 197 | + // Create a sub folder within the first sub folder which shares a name with one of the root sub folders | |
| 198 | + $parentId = $sub_folder_id[0][0]; | |
| 199 | + $folderName = 'Test api sub-folder TWO'; | |
| 200 | + $url = $this->rootUrl.'method=create_folder&session_id=' . $session_id . '&folder_id=' . $parentId . '&folder_name=' . urlencode($folderName); | |
| 201 | + $response = $this->call($url); | |
| 202 | + $response = $response['response']; | |
| 203 | + $sub_folder_id[0][] = $response['results']['id']; | |
| 204 | + $folders[$parentId][$response['results']['id']] = $folderName; | |
| 205 | + $this->assertEqual($response['status_code'], 0); | |
| 206 | + | |
| 207 | + // Create a second sub folder in the first sub folder | |
| 208 | + $parentId = $root_folder_id[0]; | |
| 209 | + $folderName = 'Test api sub-folder FOUR'; | |
| 210 | + $url = $this->rootUrl.'method=create_folder&session_id=' . $session_id . '&folder_id=' . $parentId . '&folder_name=' . urlencode($folderName); | |
| 211 | + $response = $this->call($url); | |
| 212 | + $response = $response['response']; | |
| 213 | + $sub_folder_id[0][] = $response['results']['id']; | |
| 214 | + $folders[$parentId][$response['results']['id']] = $folderName; | |
| 215 | + $this->assertEqual($response['status_code'], 0); | |
| 216 | + | |
| 217 | + // Create a sub folder within the second sub folder | |
| 218 | + $parentId = $root_folder_id[1]; | |
| 219 | + $folderName = 'Test api sub-folder FIVE'; | |
| 220 | + $url = $this->rootUrl.'method=create_folder&session_id=' . $session_id . '&folder_id=' . $parentId . '&folder_name=' . urlencode($folderName); | |
| 221 | + $response = $this->call($url); | |
| 222 | + $response = $response['response']; | |
| 223 | + $sub_folder_id[1][] = $response['results']['id']; | |
| 224 | + $folders[$parentId][$response['results']['id']] = $folderName; | |
| 225 | + $this->assertEqual($response['status_code'], 0); | |
| 226 | + | |
| 227 | + // Create a sub folder within the second sub folder which shares a name with a sub folder in the first sub folder | |
| 228 | + $parentId = $sub_folder_id[1][0]; | |
| 229 | + $folderName = 'Test api sub-folder THREE'; | |
| 230 | + $url = $this->rootUrl.'method=create_folder&session_id=' . $session_id . '&folder_id=' . $parentId . '&folder_name=' . urlencode($folderName); | |
| 231 | + $response = $this->call($url); | |
| 232 | + $response = $response['response']; | |
| 233 | + $sub_folder_id[1][] = $response['results']['id']; | |
| 234 | + $folders[$parentId][$response['results']['id']] = $folderName; | |
| 235 | + $this->assertEqual($response['status_code'], 0); | |
| 236 | + | |
| 237 | + // NOTE default parent is 1, so does not need to be declared when searching the root folder, but we use it elsewhere | |
| 238 | + | |
| 239 | + // Fetching of root folder | |
| 240 | + $parentId = 0; | |
| 241 | + $folderName = 'Root Folder'; | |
| 242 | + $url = $this->rootUrl.'method=get_folder_detail_by_name&session_id=' . $session_id . '&folder_name=' . urlencode($folderName); | |
| 243 | + $response = $this->call($url); | |
| 244 | + $response = $response['response']; | |
| 245 | + $this->assertEqual($response['status_code'], 0); | |
| 246 | + $this->assertFalse(!empty($response['message'])); | |
| 247 | + if (($response['status_code'] == 0)) { | |
| 248 | + $this->assertEqual($folders[$parentId][$response['results']['id']], $folderName); | |
| 249 | + } | |
| 250 | + | |
| 251 | + // Folder Detail by Name in root folder (no duplicate names) | |
| 252 | + $parentId = 1; | |
| 253 | + $folderName = 'Test api sub-folder ONE'; | |
| 254 | + // no parent required | |
| 255 | + $url = $this->rootUrl.'method=get_folder_detail_by_name&session_id=' . $session_id . '&folder_name=' . urlencode($folderName); | |
| 256 | + $response = $this->call($url); | |
| 257 | + $response = $response['response']; | |
| 258 | + $this->assertEqual($response['status_code'], 0); | |
| 259 | + $this->assertFalse(!empty($response['message'])); | |
| 260 | + if (($response['status_code'] == 0)) { | |
| 261 | + $this->assertEqual($folders[$parentId][$response['results']['id']], $folderName); | |
| 262 | + } | |
| 263 | + | |
| 264 | + // Folder Detail by Name in sub folder of root folder (no duplicate names) | |
| 265 | + $parentId = $root_folder_id[0]; | |
| 266 | + $folderName = 'Test api sub-folder FOUR'; | |
| 267 | + $url = $this->rootUrl.'method=get_folder_detail_by_name&session_id=' . $session_id . '&parent_id=' . $parentId . '&folder_name=' . urlencode($folderName); | |
| 268 | + $response = $this->call($url); | |
| 269 | + $response = $response['response']; | |
| 270 | + $this->assertEqual($response['status_code'], 0); | |
| 271 | + $this->assertFalse(!empty($response['message'])); | |
| 272 | + if (($response['status_code'] == 0)) { | |
| 273 | + $this->assertEqual($folders[$parentId][$response['results']['id']], $folderName); | |
| 274 | + } | |
| 275 | + | |
| 276 | + // Folder Detail by Name in root folder (duplicate names) | |
| 277 | + $parentId = 1; | |
| 278 | + $folderName = 'Test api sub-folder TWO'; | |
| 279 | + $url = $this->rootUrl.'method=get_folder_detail_by_name&session_id=' . $session_id . '&parent_id=' . $parentId . '&folder_name=' . urlencode($folderName); | |
| 280 | + $response = $this->call($url); | |
| 281 | + $response = $response['response']; | |
| 282 | + $this->assertEqual($response['status_code'], 0); | |
| 283 | + $this->assertFalse(!empty($response['message'])); | |
| 284 | + if (($response['status_code'] == 0)) { | |
| 285 | + $this->assertEqual($folders[$parentId][$response['results']['id']], $folderName); | |
| 286 | + } | |
| 287 | + | |
| 288 | + // Folder Detail by Name in sub folder of root folder (duplicate names) | |
| 289 | + $parentId = $root_folder_id[0]; | |
| 290 | + $folderName = 'Test api sub-folder THREE'; | |
| 291 | + $url = $this->rootUrl.'method=get_folder_detail_by_name&session_id=' . $session_id . '&parent_id=' . $parentId . '&folder_name=' . urlencode($folderName); | |
| 292 | + $response = $this->call($url); | |
| 293 | + $response = $response['response']; | |
| 294 | + $this->assertEqual($response['status_code'], 0); | |
| 295 | + $this->assertFalse(!empty($response['message'])); | |
| 296 | + if (($response['status_code'] == 0)) { | |
| 297 | + $this->assertEqual($folders[$parentId][$response['results']['id']], $folderName); | |
| 298 | + } | |
| 299 | + | |
| 300 | + // Negative test with non duplicated folder - look for folder in location it does not exist | |
| 301 | + $parentId = $root_folder_id[0]; | |
| 302 | + $folderName = 'Test api sub-folder ONE'; | |
| 303 | + $url = $this->rootUrl.'method=get_folder_detail_by_name&session_id=' . $session_id . '&parent_id=' . $parentId . '&folder_name=' . urlencode($folderName); | |
| 304 | + $response = $this->call($url); | |
| 305 | + $response = $response['response']; | |
| 306 | + $this->assertNotEqual($response['status_code'], 0); | |
| 307 | + $this->assertTrue(!empty($response['message'])); | |
| 308 | + $this->assertNotEqual($folders[$parentId][$response['results']['id']], $folderName); | |
| 309 | + | |
| 310 | + // Negative test with duplicated folder - look for folder with incorrect parent id, result should not match expected folder | |
| 311 | + $parentId = 1; | |
| 312 | + $actualParentId = $sub_folder_id[0][0]; | |
| 313 | + $folderName = 'Test api sub-folder TWO'; | |
| 314 | + $url = $this->rootUrl.'method=get_folder_detail_by_name&session_id=' . $session_id . '&parent_id=' . $parentId . '&folder_name=' . urlencode($folderName); | |
| 315 | + $response = $this->call($url); | |
| 316 | + $response = $response['response']; | |
| 317 | + // we should get a result | |
| 318 | + $this->assertEqual($response['status_code'], 0); | |
| 319 | + $this->assertFalse(!empty($response['message'])); | |
| 320 | + // but not the one we wanted | |
| 321 | + $url = $this->rootUrl.'method=get_folder_detail_by_name&session_id=' . $session_id . '&parent_id=' . $actualParentId . '&folder_name=' . urlencode($folderName); | |
| 322 | + $expectedResponse = $this->call($url); | |
| 323 | + $expectedResponse = $expectedResponse['response']; | |
| 324 | + $this->assertNotEqual($response['results']['id'], $expectedResponse['results']['id']); | |
| 325 | + | |
| 326 | + // Clean up - delete all of the folders | |
| 327 | + foreach ($root_folder_id as $folder_id) { | |
| 328 | + $url = $this->rootUrl.'method=delete_folder&session_id=' . $session_id . '&folder_id=' . $folder_id . '&reason=Testing%20Webservice'; | |
| 329 | + $this->call($url); | |
| 330 | + } | |
| 331 | + | |
| 332 | + foreach ($sub_folder_id as $_folder_id_) { | |
| 333 | + foreach ($_folder_id_ as $folder_id) { | |
| 334 | + $url = $this->rootUrl.'method=delete_folder&session_id=' . $session_id . '&folder_id=' . $folder_id . '&reason=Testing%20Webservice'; | |
| 335 | + $this->call($url); | |
| 336 | + } | |
| 337 | + } | |
| 338 | + | |
| 339 | + // Logout | |
| 340 | + $url = $this->rootUrl.'method=logout&session_id='.$session_id; | |
| 341 | + $response = $this->call($url); | |
| 342 | + $response = $response['response']; | |
| 343 | + } | |
| 140 | 344 | |
| 141 | 345 | /** |
| 142 | 346 | * Convert xml into an array structure | ... | ... |
tests/webservices/testSoap.php
0 โ 100644
| 1 | +<?php | |
| 2 | +require_once (KT_DIR . '/tests/test.php'); | |
| 3 | + | |
| 4 | +/** | |
| 5 | +* These are the unit tests for the SOAP webservice | |
| 6 | +* | |
| 7 | +*/ | |
| 8 | +class SOAPTestCase extends KTUnitTestCase { | |
| 9 | + | |
| 10 | + /** | |
| 11 | + * @var object $session The KT session object | |
| 12 | + */ | |
| 13 | + var $session; | |
| 14 | + | |
| 15 | + /** | |
| 16 | + * @var string $rootUrl The root server url for the rest web service | |
| 17 | + */ | |
| 18 | + var $rootUrl; | |
| 19 | + | |
| 20 | + public $client; | |
| 21 | + private $user; | |
| 22 | + private $pass; | |
| 23 | + | |
| 24 | + /** | |
| 25 | + * This method sets up the server url | |
| 26 | + * | |
| 27 | + */ | |
| 28 | + public function setUp() | |
| 29 | + { | |
| 30 | + $url = KTUtil::kt_url(); | |
| 31 | + $this->rootUrl = $url.'/ktwebservice/webservice.php?'; | |
| 32 | + $this->user = isset($_GET['user']) ? $_GET['user'] : 'admin'; | |
| 33 | + $this->pass = isset($_GET['pass']) ? $_GET['pass'] : 'admin'; | |
| 34 | + } | |
| 35 | + | |
| 36 | + /** | |
| 37 | + * This method is a placeholder | |
| 38 | + */ | |
| 39 | + public function tearDown() | |
| 40 | + { | |
| 41 | + } | |
| 42 | + | |
| 43 | + function connect() | |
| 44 | + { | |
| 45 | + $wsdl = $this->rootUrl . "wsdl"; | |
| 46 | + $this->client = new SoapClient($wsdl); | |
| 47 | + } | |
| 48 | + | |
| 49 | + function login($ip = null) | |
| 50 | + { | |
| 51 | + $res = $this->client->__soapCall("login", array($this->user, $this->pass, $ip)); | |
| 52 | + if($res->status_code != 0){ | |
| 53 | + return false; | |
| 54 | + } | |
| 55 | + $this->session = $res->message; | |
| 56 | + } | |
| 57 | + | |
| 58 | + | |
| 59 | + function getDocTypes() | |
| 60 | + { | |
| 61 | + $result = $this->client->__soapCall("get_document_types", array($this->session)); | |
| 62 | + return $result->document_types; | |
| 63 | + } | |
| 64 | + | |
| 65 | + function search($expr) | |
| 66 | + { | |
| 67 | + $result = $this->client->__soapCall("search", array($this->session, $expr, '')); | |
| 68 | + return $result->hits; | |
| 69 | + } | |
| 70 | + | |
| 71 | + function getFolderDetail($folder, $parentId = 1) | |
| 72 | + { | |
| 73 | + $result = $this->client->__soapCall("get_folder_detail_by_name", array($this->session, $folder, $parentId)); | |
| 74 | + return $result; | |
| 75 | + } | |
| 76 | + | |
| 77 | + function createFolder($parent_id, $folder) | |
| 78 | + { | |
| 79 | + $result = $this->client->__soapCall("create_folder", array($this->session, $parent_id, $folder)); | |
| 80 | + return $result; | |
| 81 | + } | |
| 82 | + | |
| 83 | + function deleteFolder($folder_id) | |
| 84 | + { | |
| 85 | + $result = $this->client->__soapCall("delete_folder", array($this->session, "$folder_id", 'Testing')); | |
| 86 | + return $result; | |
| 87 | + } | |
| 88 | + | |
| 89 | + function logout() | |
| 90 | + { | |
| 91 | + $result = $this->client->__soapCall("logout", array($this->session)); | |
| 92 | + if($result->status_code != 0){ | |
| 93 | + return true; | |
| 94 | + } | |
| 95 | + } | |
| 96 | + | |
| 97 | + // now the test functions | |
| 98 | + | |
| 99 | + /** | |
| 100 | + * Tests finding of a folder or folder detail by name | |
| 101 | + * Runs the following sub-tests: | |
| 102 | + * . Folder Detail by Name in root folder (no duplicate names) | |
| 103 | + * . Folder Detail by Name in subfolder of root folder (no duplicate names) | |
| 104 | + * . Folder Detail by Name in subfolder of root folder (duplicate names) | |
| 105 | + * | |
| 106 | + * NOTE there are less tests here because we cannot test the get_folder_by_name function since it does not exist within the web service code | |
| 107 | + */ | |
| 108 | + public function testGetFolderByName() | |
| 109 | + { | |
| 110 | + // Login and authenticate | |
| 111 | + $this->connect(); | |
| 112 | + $this->login('127.0.0.1'); | |
| 113 | + | |
| 114 | + // set up | |
| 115 | + $root_folder_id = array(); | |
| 116 | + $sub_folder_id = array(); | |
| 117 | + $folders[0][1] = 'Root Folder'; | |
| 118 | + | |
| 119 | + // Create a sub folder in the root folder | |
| 120 | + $parentId = 1; | |
| 121 | + $folderName = 'Test api sub-folder ONE'; | |
| 122 | + $response = $this->createFolder($parentId, $folderName); | |
| 123 | + $root_folder_id[] = $response->id; | |
| 124 | + $folders[$parentId][$response->id] = $folderName; | |
| 125 | + $this->assertEqual($response->status_code, 0); | |
| 126 | + $this->assertFalse(!empty($response->message)); | |
| 127 | + | |
| 128 | + // Create a second sub folder in the root folder | |
| 129 | + $parentId = 1; | |
| 130 | + $folderName = 'Test api sub-folder TWO'; | |
| 131 | + $response = $this->createFolder($parentId, $folderName); | |
| 132 | + $root_folder_id[] = $response->id; | |
| 133 | + $folders[$parentId][$response->id] = $folderName; | |
| 134 | + $this->assertEqual($response->status_code, 0); | |
| 135 | + $this->assertFalse(!empty($response->message)); | |
| 136 | + | |
| 137 | + // Create a sub folder in the first sub folder | |
| 138 | + $parentId = $root_folder_id[0]; | |
| 139 | + $folderName = 'Test api sub-folder THREE'; | |
| 140 | + $response = $this->createFolder($parentId, $folderName); | |
| 141 | + $sub_folder_id[0][] = $response->id; | |
| 142 | + $folders[$parentId][$response->id] = $folderName; | |
| 143 | + $this->assertEqual($response->status_code, 0); | |
| 144 | + $this->assertFalse(!empty($response->message)); | |
| 145 | + | |
| 146 | + // Create a sub folder within the first sub folder which shares a name with one of the root sub folders | |
| 147 | + $parentId = $sub_folder_id[0][0]; | |
| 148 | + $folderName = 'Test api sub-folder TWO'; | |
| 149 | + $response = $this->createFolder($parentId, $folderName); | |
| 150 | + $sub_folder_id[0][] = $response->id; | |
| 151 | + $folders[$parentId][$response->id] = $folderName; | |
| 152 | + $this->assertEqual($response->status_code, 0); | |
| 153 | + $this->assertFalse(!empty($response->message)); | |
| 154 | + | |
| 155 | + // Create a second sub folder in the first sub folder | |
| 156 | + $parentId = $root_folder_id[0]; | |
| 157 | + $folderName = 'Test api sub-folder FOUR'; | |
| 158 | + $response = $this->createFolder($parentId, $folderName); | |
| 159 | + $sub_folder_id[0][] = $response->id; | |
| 160 | + $folders[$parentId][$response->id] = $folderName; | |
| 161 | + $this->assertEqual($response->status_code, 0); | |
| 162 | + $this->assertFalse(!empty($response->message)); | |
| 163 | + | |
| 164 | + // Create a sub folder within the second sub folder | |
| 165 | + $parentId = $root_folder_id[1]; | |
| 166 | + $folderName = 'Test api sub-folder FIVE'; | |
| 167 | + $response = $this->createFolder($parentId, $folderName); | |
| 168 | + $sub_folder_id[1][] = $response->id; | |
| 169 | + $folders[$parentId][$response->id] = $folderName; | |
| 170 | + $this->assertEqual($response->status_code, 0); | |
| 171 | + $this->assertFalse(!empty($response->message)); | |
| 172 | + | |
| 173 | + // Create a sub folder within the second sub folder which shares a name with a sub folder in the first sub folder | |
| 174 | + $parentId = $sub_folder_id[1][0]; | |
| 175 | + $folderName = 'Test api sub-folder THREE'; | |
| 176 | + $response = $this->createFolder($parentId, $folderName); | |
| 177 | + $sub_folder_id[1][] = $response->id; | |
| 178 | + $folders[$parentId][$response->id] = $folderName; | |
| 179 | + $this->assertEqual($response->status_code, 0); | |
| 180 | + $this->assertFalse(!empty($response->message)); | |
| 181 | + | |
| 182 | + // NOTE default parent is 1, so does not need to be declared when searching the root folder, but we use it elsewhere | |
| 183 | + | |
| 184 | + // Fetching of root folder | |
| 185 | + $parentId = 0; | |
| 186 | + $folderName = 'Root Folder'; | |
| 187 | + $response = $this->getFolderDetail($folderName); | |
| 188 | + $this->assertEqual($response->status_code, 0); | |
| 189 | + $this->assertFalse(!empty($response->message)); | |
| 190 | + if (($response->status_code == 0)) { | |
| 191 | + $this->assertEqual($folders[$parentId][$response->id], $folderName); | |
| 192 | + } | |
| 193 | + | |
| 194 | + // Folder Detail by Name in root folder (no duplicate names) | |
| 195 | + $parentId = 1; | |
| 196 | + $folderName = 'Test api sub-folder ONE'; | |
| 197 | + // no parent required | |
| 198 | + $response = $this->getFolderDetail($folderName); | |
| 199 | + $this->assertEqual($response->status_code, 0); | |
| 200 | + $this->assertFalse(!empty($response->message)); | |
| 201 | + if (($response->status_code == 0)) { | |
| 202 | + $this->assertEqual($folders[$parentId][$response->id], $folderName); | |
| 203 | + } | |
| 204 | + | |
| 205 | + // Folder Detail by Name in sub folder of root folder (no duplicate names) | |
| 206 | + $parentId = $root_folder_id[0]; | |
| 207 | + $folderName = 'Test api sub-folder FOUR'; | |
| 208 | + $response = $this->getFolderDetail($folderName, $parentId); | |
| 209 | + $this->assertEqual($response->status_code, 0); | |
| 210 | + $this->assertFalse(!empty($response->message)); | |
| 211 | + if (($response->status_code == 0)) { | |
| 212 | + $this->assertEqual($folders[$parentId][$response->id], $folderName); | |
| 213 | + } | |
| 214 | + | |
| 215 | + // Folder Detail by Name in root folder (duplicate names) | |
| 216 | + $parentId = 1; | |
| 217 | + $folderName = 'Test api sub-folder TWO'; | |
| 218 | + $response = $this->getFolderDetail($folderName, $parentId); | |
| 219 | + $this->assertEqual($response->status_code, 0); | |
| 220 | + $this->assertFalse(!empty($response->message)); | |
| 221 | + if (($response->status_code == 0)) { | |
| 222 | + $this->assertEqual($folders[$parentId][$response->id], $folderName); | |
| 223 | + } | |
| 224 | + | |
| 225 | + // Folder Detail by Name in sub folder of root folder (duplicate names) | |
| 226 | + $parentId = $root_folder_id[0]; | |
| 227 | + $folderName = 'Test api sub-folder THREE'; | |
| 228 | + $response = $this->getFolderDetail($folderName, $parentId); | |
| 229 | + $this->assertEqual($response->status_code, 0); | |
| 230 | + $this->assertFalse(!empty($response->message)); | |
| 231 | + if (($response->status_code == 0)) { | |
| 232 | + $this->assertEqual($folders[$parentId][$response->id], $folderName); | |
| 233 | + } | |
| 234 | + | |
| 235 | + // Negative test with non duplicated folder - look for folder in location it does not exist | |
| 236 | + $parentId = $root_folder_id[0]; | |
| 237 | + $folderName = 'Test api sub-folder ONE'; | |
| 238 | + $response = $this->getFolderDetail($folderName, $parentId); | |
| 239 | + $this->assertNotEqual($response->status_code, 0); | |
| 240 | + $this->assertTrue(!empty($response->message)); | |
| 241 | + $this->assertNotEqual($folders[$parentId][$response->id], $folderName); | |
| 242 | + | |
| 243 | + // Negative test with duplicated folder - look for folder with incorrect parent id, result should not match expected folder | |
| 244 | + $parentId = 1; | |
| 245 | + $actualParentId = $sub_folder_id[0][0]; | |
| 246 | + $folderName = 'Test api sub-folder TWO'; | |
| 247 | + $response = $this->getFolderDetail($folderName, $parentId); | |
| 248 | + // we should get a result | |
| 249 | + $this->assertEqual($response->status_code, 0); | |
| 250 | + $this->assertFalse(!empty($response->message)); | |
| 251 | + // but not the one we wanted | |
| 252 | + $expectedResponse = $this->getFolderDetail($folderName, $actualParentId); | |
| 253 | + $this->assertNotEqual($response->id, $expectedResponse->id); | |
| 254 | + | |
| 255 | + // Clean up - delete all of the folders | |
| 256 | + foreach ($root_folder_id as $folder_id) { | |
| 257 | + $this->deleteFolder($folder_id); | |
| 258 | + } | |
| 259 | + | |
| 260 | + // Logout | |
| 261 | + $this->logout(); | |
| 262 | + } | |
| 263 | + | |
| 264 | +} | |
| 265 | +?> | |
| 0 | 266 | \ No newline at end of file | ... | ... |