diff --git a/quickbase.php b/quickbase.php index 1229079..882de06 100644 --- a/quickbase.php +++ b/quickbase.php @@ -33,7 +33,8 @@ class QuickBase { 'includeRids' => true, 'returnPercentage' => false, 'fmt' => 'structured', - 'encoding' => 'UTF-8' + 'encoding' => 'UTF-8', + 'dbidAsParam' => false ), 'status' => array( @@ -58,8 +59,6 @@ final public function api($action, $options = array()){ ->actionRequest() ->constructPayload() ->transmit() - ->processResponse() - ->checkForAndHandleError() ->actionResponse(); return $query->response; @@ -104,10 +103,10 @@ class QuickBaseQuery { public $response = array(); protected $payload = ''; - protected $xmlResponse = array(); public function __construct(&$parent, $action = '', $options = array()){ $this->parent = $parent; + $this->settings = array_replace_recursive(array(), $this->parent->settings); $this->action = $action; $this->options = $options; @@ -131,20 +130,20 @@ final public function actionResponse(){ } final public function addFlags(){ - if(!isset($this->options['msInUTC']) && $this->parent->settings['flags']['msInUTC']){ + if(!isset($this->options['msInUTC']) && $this->settings['flags']['msInUTC']){ $this->options['msInUTC'] = 1; } - if(!isset($this->options['appToken']) && $this->parent->settings['appToken']){ - $this->options['appToken'] = $this->parent->settings['appToken']; + if(!isset($this->options['appToken']) && $this->settings['appToken']){ + $this->options['appToken'] = $this->settings['appToken']; } - if(!isset($this->options['ticket']) && $this->parent->settings['ticket']){ - $this->options['ticket'] = $this->parent->settings['ticket']; + if(!isset($this->options['ticket']) && $this->settings['ticket']){ + $this->options['ticket'] = $this->settings['ticket']; } - if(!isset($this->options['encoding']) && $this->parent->settings['flags']['encoding']){ - $this->options['encoding'] = $this->parent->settings['flags']['encoding']; + if(!isset($this->options['encoding']) && $this->settings['flags']['encoding']){ + $this->options['encoding'] = $this->settings['flags']['encoding']; } return $this; @@ -153,7 +152,7 @@ final public function addFlags(){ final public function constructPayload(){ $this->payload = ''; - if($this->parent->settings['flags']['useXML']){ + if($this->settings['flags']['useXML']){ $xmlDoc = new SimpleXMLElement(implode('', array( 'options['encoding'], @@ -174,7 +173,7 @@ final public function constructPayload(){ } final public function checkForAndHandleError(){ - if($this->response['errcode'] != $this->parent->settings['status']['errcode']){ + if($this->response['errcode'] != $this->settings['status']['errcode']){ if($this->response['errcode'] == 4 && isset($this->parent->settings['username']) && isset($this->parent->settings['password'])){ try { $newTicket = $this->parent->api('API_Authenticate', array( @@ -183,13 +182,12 @@ final public function checkForAndHandleError(){ )); $this->parent->settings['ticket'] = $newTicket['ticket']; + $this->settings['ticket'] = $newTicket['ticket']; $this->options['ticket'] = $newTicket['ticket']; return $this ->constructPayload() - ->transmit() - ->processResponse() - ->checkForAndHandleError(); + ->transmit(); }catch(Exception $newTicketErr){ throw $newTicketErr; } @@ -217,35 +215,26 @@ final public function processOptions(){ return $this; } - final public function processResponse(){ - $this->response = array(); - - $this->xml2Arr($this->xmlResponse, $this->response); - - $this->cleanXml2Arr($this->response); - - return $this; - } - final public function transmit(){ $ch = curl_init(implode('', array( - $this->parent->settings['useSSL'] ? 'https://' : 'http://', - $this->parent->settings['realm'], + $this->settings['useSSL'] ? 'https://' : 'http://', + $this->settings['realm'], '.', - $this->parent->settings['domain'], + $this->settings['domain'], '/db/', - isset($this->options['dbid']) ? $this->options['dbid'] : 'main', + isset($this->options['dbid']) && !$this->settings['flags']['dbidAsParam'] ? $this->options['dbid'] : 'main', '?act=', $this->action, - $this->parent->settings['flags']['useXML'] ? '' : $this->payload + $this->settings['flags']['useXML'] ? '' : $this->payload ))); - curl_setopt($ch, CURLOPT_PORT, $this->parent->settings['useSSL'] ? 443 : 80); + curl_setopt($ch, CURLOPT_PORT, $this->settings['useSSL'] ? 443 : 80); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); - if($this->parent->settings['flags']['useXML']){ + if($this->settings['flags']['useXML']){ curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'POST /db/'.(isset($this->options['dbid']) ? $this->options['dbid'] : 'main').' HTTP/1.0', @@ -264,13 +253,32 @@ final public function transmit(){ $errno = curl_errno($ch); $error = curl_error($ch); + $headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE); + curl_close($ch); if($response === false){ throw new QuickBaseError($errno, $error); } - $this->xmlResponse = new SimpleXmlIterator($response); + $headers = substr($response, 0, $headerSize); + $body = substr($response, $headerSize); + + self::parseCURLHeaders($headers); + + if($headers['Content-Type'] === 'application/xml'){ + $this->response = array(); + + $xml = new SimpleXmlIterator($body); + + $this->xml2Arr($xml, $this->response); + + $this->cleanXml2Arr($this->response); + + $this->checkForAndHandleError(); + }else{ + $this->response = $body; + } return $this; } @@ -355,6 +363,19 @@ final protected static function cleanXml2Arr(&$arr){ } } + final protected static function parseCURLHeaders(&$headers){ + $newHeaders = array(); + $headers = explode("\r\n", $headers); + + foreach($headers as $header){ + $i = strpos($header, ':'); + + $newHeaders[substr($header, 0, $i)] = substr($header, $i + 2); + } + + $headers = $newHeaders; + } + final protected static function xml2Arr($xml, &$arr){ for($xml->rewind(); $xml->valid(); $xml->next()){ $key = $xml->key(); @@ -408,7 +429,7 @@ class QuickBaseRequest { final public static function API_Authenticate(&$query){ // API_Authenticate can only happen over SSL - $query->parent->settings['useSSL'] = true; + $query->settings['useSSL'] = true; } // final public static function API_ChangeGroupInfo(&$query){ } @@ -427,16 +448,16 @@ final public static function API_Authenticate(&$query){ // final public static function API_DeleteRecord(&$query){ } final public static function API_DoQuery(&$query){ - if(!isset($query->options['returnPercentage']) && isset($query->parent->settings['flags']['returnPercentage'])){ - $query->options['returnPercentage'] = $query->parent->settings['flags']['returnPercentage']; + if(!isset($query->options['returnPercentage']) && isset($query->settings['flags']['returnPercentage'])){ + $query->options['returnPercentage'] = $query->settings['flags']['returnPercentage']; } - if(!isset($query->options['fmt']) && isset($query->parent->settings['flags']['fmt'])){ - $query->options['fmt'] = $query->parent->settings['flags']['fmt']; + if(!isset($query->options['fmt']) && isset($query->settings['flags']['fmt'])){ + $query->options['fmt'] = $query->settings['flags']['fmt']; } - if(!isset($query->options['includeRids']) && isset($query->parent->settings['flags']['includeRids'])){ - $query->options['includeRids'] = $query->parent->settings['flags']['includeRids']; + if(!isset($query->options['includeRids']) && isset($query->settings['flags']['includeRids'])){ + $query->options['includeRids'] = $query->settings['flags']['includeRids']; } } @@ -448,7 +469,11 @@ final public static function API_DoQuery(&$query){ // final public static function API_GenAddRecordForm(&$query){ } // final public static function API_GenResultsTable(&$query){ } // final public static function API_GetAncestorInfo(&$query){ } - // final public static function API_GetAppDTMInfo(&$query){ } + + final public static function API_GetAppDTMInfo(&$query){ + $query->settings['flags']['dbidAsParam'] = true; + } + // final public static function API_GetDBPage(&$query){ } // final public static function API_GetDBInfo(&$query){ } // final public static function API_GetDBVar(&$query){ } @@ -500,8 +525,13 @@ class QuickBaseResponse { final public static function API_Authenticate(&$query, &$results){ $query->parent->settings['ticket'] = $results['ticket']; + $query->settings['ticket'] = $results['ticket']; + $query->parent->settings['username'] = $query->options['username']; + $query->settings['username'] = $query->options['username']; + $query->parent->settings['password'] = $query->options['password']; + $query->settings['password'] = $query->options['password']; } // final public static function API_ChangeGroupInfo(&$query, &$results){ } @@ -654,11 +684,30 @@ final public static function API_GetSchema(&$query, &$results){ // final public static function API_GetRecordAsHTML(&$query, &$results){ } // final public static function API_GetRecordInfo(&$query, &$results){ } - // final public static function API_GetRoleInfo(&$query, &$results){ } + + final public static function API_GetRoleInfo(&$query, &$results){ + if(isset($results['roles']['id'])){ + $results['roles'] = array( $results['roles'] ); + } + + for($i = 0, $l = count($results['roles']); $i < $l; ++$i){ + $results['roles'][$i]['access'] = array( + 'name' => $results['roles'][$i]['access']['_'], + 'id' => $results['roles'][$i]['access']['id'] + ); + } + } + // final public static function API_GetUserInfo(&$query, &$results){ } // final public static function API_GetUserRole(&$query, &$results){ } // final public static function API_GetUsersInGroup(&$query, &$results){ } - // final public static function API_GrantedDBs(&$query, &$results){ } + + final public static function API_GrantedDBs(&$query, &$results){ + if(isset($results['databases']['dbinfo'])){ + $results['databases'] = $results['databases']['dbinfo']; + } + } + // final public static function API_GrantedDBsForGroup(&$query, &$results){ } // final public static function API_GrantedGroups(&$query, &$results){ } // final public static function API_ImportFromCSV(&$query, &$results){ } @@ -676,7 +725,17 @@ final public static function API_GetSchema(&$query, &$results){ // final public static function API_SetKeyField(&$query, &$results){ } // final public static function API_SignOut(&$query, &$results){ } // final public static function API_UploadFile(&$query, &$results){ } - // final public static function API_UserRoles(&$query, &$results){ } + + final public static function API_UserRoles(&$query, &$results){ + for($i = 0, $l = count($results['users']); $i < $l; ++$i){ + for($o = 0, $k = count($results['users'][$i]['roles']); $o < $k; ++$o){ + $results['users'][$i]['roles'][$o]['access'] = array( + 'name' => $results['users'][$i]['roles'][$o]['access']['_'], + 'id' => $results['users'][$i]['roles'][$o]['access']['id'] + ); + } + } + } } diff --git a/tests/API_AddReplaceDBPage.php b/tests/API_AddReplaceDBPage.php new file mode 100644 index 0000000..56e5b02 --- /dev/null +++ b/tests/API_AddReplaceDBPage.php @@ -0,0 +1,36 @@ + 'API_AddReplaceDBPage.js', + 'errcode' => 0, + 'errtext' => 'No error', + 'pageID' => 0 +); + +$actual = $qb->api('API_AddReplaceDBPage', array( + 'dbid' => getenv('appid'), + 'pagename' => 'testpage.html', + 'pagetype' => 1, + 'pagebody' => '' +)); + +if(!objStrctMatch($actual, $expected)){ + throw new Exception('Mismatched API_AddReplaceDBPage Data Structure'); +} + +?> diff --git a/tests/API_CreateDatabase.php b/tests/API_CreateDatabase.php new file mode 100644 index 0000000..9e65928 --- /dev/null +++ b/tests/API_CreateDatabase.php @@ -0,0 +1,55 @@ + 'API_CreateDatabase', + 'errcode' => 0, + 'errtext' => 'No error', + 'dbid' => '', + 'appdbid' => '', + 'apptoken' => '' +); + +$actual = $qb->api('API_CreateDatabase', array( + 'dbname' => 'Test DB', + 'dbdesc' => 'Testing DB from Node-QuickBase Tests', + 'createapptoken' => true +)); + +if(!objStrctMatch($actual, $expected)){ + throw new Exception('Mismatched API_CreateDatabase Data Structure'); +} + +$expected = array( + 'action' => 'API_DeleteDatabase', + 'errcode' => 0, + 'errtext' => 'No error' +); + +$actual = $qb->api('API_DeleteDatabase', array( + 'dbid' => $actual['appdbid'] +)); + +if(!objStrctMatch($actual, $expected)){ + throw new Exception('Mismatched API_DeleteDatabase Data Structure'); +} + +?> diff --git a/tests/API_CreateTable.php b/tests/API_CreateTable.php new file mode 100644 index 0000000..01a71de --- /dev/null +++ b/tests/API_CreateTable.php @@ -0,0 +1,53 @@ + 'API_CreateTable', + 'errcode' => 0, + 'errtext' => 'No error', + 'newdbid' => '' +); + +$actual = $qb->api('API_CreateTable', array( + 'dbid' => getenv('appid'), + 'tname' => 'Test DB', + 'pnoun' => 'Test DB' +)); + +if(!objStrctMatch($actual, $expected)){ + throw new Exception('Mismatched API_CreateTable Data Structure'); +} + +$expected = array( + 'action' => 'API_DeleteDatabase', + 'errcode' => 0, + 'errtext' => 'No error' +); + +$actual = $qb->api('API_DeleteDatabase', array( + 'dbid' => $actual['newdbid'] +)); + +if(!objStrctMatch($actual, $expected)){ + throw new Exception('Mismatched API_DeleteDatabase Data Structure'); +} + +?> diff --git a/tests/API_FindDBByName.php b/tests/API_FindDBByName.php new file mode 100644 index 0000000..6d8b9a1 --- /dev/null +++ b/tests/API_FindDBByName.php @@ -0,0 +1,35 @@ + 'API_FindDBByName.js', + 'errcode' => 0, + 'errtext' => 'No error', + 'dbid' => '', + 'dbname' => '' +); + +/* Main */ +$actual = $qb->api('API_FindDBByName', array( + 'dbname' => 'Node-QuickBase' +)); + +if(!objStrctMatch($actual, $expected)){ + throw new Exception('Mismatched API_FindDBByName Data Structure'); +} + +?> diff --git a/tests/API_GenAddRecordForm.php b/tests/API_GenAddRecordForm.php new file mode 100644 index 0000000..18de457 --- /dev/null +++ b/tests/API_GenAddRecordForm.php @@ -0,0 +1,28 @@ +'; + +$actual = $qb->api('API_GenAddRecordForm', array( + 'dbid' => getenv('dbid') +)); + +if(!objStrctMatch($actual, $expected)){ + throw new Exception('Mismatched API_GenAddRecordForm Data Structure'); +} + +?> \ No newline at end of file diff --git a/tests/API_GenResultsTable.php b/tests/API_GenResultsTable.php new file mode 100644 index 0000000..5531eba --- /dev/null +++ b/tests/API_GenResultsTable.php @@ -0,0 +1,28 @@ +'; + +$actual = $qb->api('API_GenResultsTable', array( + 'dbid' => getenv('dbid') +)); + +if(!objStrctMatch($actual, $expected)){ + throw new Exception('Mismatched API_GenResultsTable Data Structure'); +} + +?> diff --git a/tests/API_GetAncestorInfo.php b/tests/API_GetAncestorInfo.php new file mode 100644 index 0000000..4d27f41 --- /dev/null +++ b/tests/API_GetAncestorInfo.php @@ -0,0 +1,34 @@ + 'API_GetAncestorInfo', + 'errcode' => 0, + 'errtext' => 'No error', + 'ancestorappid' => '', + 'oldestancestorappid' => '' +); + +$actual = $qb->api('API_GetAncestorInfo', array( + 'dbid' => getenv('appid') +)); + +if(!objStrctMatch($actual, $expected)){ + throw new Exception('Mismatched API_GetAncestorInfo Data Structure'); +} + +?> diff --git a/tests/API_GetAppDTMInfo.php b/tests/API_GetAppDTMInfo.php new file mode 100644 index 0000000..b98dde2 --- /dev/null +++ b/tests/API_GetAppDTMInfo.php @@ -0,0 +1,46 @@ + 'API_GetAppDTMInfo', + 'errcode' => 0, + 'errtext' => 'No error', + 'RequestTime' => 0, + 'RequestNextAllowedTime' => 0, + 'app' => array( + 'lastModifiedTime' => 0, + 'lastRecModTime' => 0, + 'id' => '' + ), + 'tables' => array( + array( + 'lastModifiedTime' => 0, + 'lastRecModTime' => 0, + 'id' => '' + ) + ) +); + +$actual = $qb->api('API_GetAppDTMInfo', array( + 'dbid' => getenv('appid') +)); + +if(!objStrctMatch($actual, $expected)){ + throw new Exception('Mismatched API_GetAppDTMInfo Data Structure'); +} + +?> diff --git a/tests/API_GetDBInfo.php b/tests/API_GetDBInfo.php new file mode 100644 index 0000000..d1bfeac --- /dev/null +++ b/tests/API_GetDBInfo.php @@ -0,0 +1,41 @@ + 'API_GetDBInfo', + 'errcode' => 0, + 'errtext' => 'No error', + 'dbname' => '', + 'lastRecModTime' => 0, + 'lastModifiedTime' => 0, + 'createdTime' => 0, + 'numRecords' => 0, + 'mgrID' => '', + 'mgrName' => '', + 'version' => 0, + 'time_zone' => '' +); + +$actual = $qb->api('API_GetDBInfo', array( + 'dbid' => getenv('appid') +)); + +if(!objStrctMatch($actual, $expected)){ + throw new Exception('Mismatched API_GetDBInfo Data Structure'); +} + +?> diff --git a/tests/API_GetDBPage.php b/tests/API_GetDBPage.php new file mode 100644 index 0000000..273897b --- /dev/null +++ b/tests/API_GetDBPage.php @@ -0,0 +1,34 @@ + 'API_GetDBPage', + 'errcode' => 0, + 'errtext' => 'No error', + 'pagebody' => '' +); + +$actual = $qb->api('API_GetDBPage', array( + 'dbid' => getenv('appid'), + 'pageID' => 2 +)); + +if(!objStrctMatch($actual, $expected)){ + throw new Exception('Mismatched API_GetDBPage Data Structure'); +} + +?> diff --git a/tests/API_GetDBVar.php b/tests/API_GetDBVar.php new file mode 100644 index 0000000..8a4c4c7 --- /dev/null +++ b/tests/API_GetDBVar.php @@ -0,0 +1,34 @@ + 'API_GetDBVar', + 'errcode' => 0, + 'errtext' => 'No error', + 'value' => '' +); + +$actual = $qb->api('API_GetDBVar', array( + 'dbid' => getenv('appid'), + 'varname' => 'test' +)); + +if(!objStrctMatch($actual, $expected)){ + throw new Exception('Mismatched API_GetDBVar Data Structure'); +} + +?> diff --git a/tests/API_GetNumRecords.php b/tests/API_GetNumRecords.php new file mode 100644 index 0000000..9486091 --- /dev/null +++ b/tests/API_GetNumRecords.php @@ -0,0 +1,34 @@ + 'API_GetNumRecords', + 'errcode' => 0, + 'errtext' => 'No error', + 'num_records' => 0 +); + +/* Main */ +$actual = $qb->api('API_GetNumRecords', array( + 'dbid' => getenv('dbid') +)); + +if(!objStrctMatch($actual, $expected)){ + throw new Exception('Mismatched API_GetNumRecords Data Structure'); +} + +?> diff --git a/tests/API_GetRoleInfo.php b/tests/API_GetRoleInfo.php new file mode 100644 index 0000000..75e0d5b --- /dev/null +++ b/tests/API_GetRoleInfo.php @@ -0,0 +1,56 @@ + 'API_GetRoleInfo', + 'errcode' => 0, + 'errtext' => 'No error', + 'roles' => array( + array( + 'id' => 0, + 'name' => '', + 'access' => array( + 'id' => 0, + 'name' => '' + ) + ), array( + 'id' => 0, + 'name' => '', + 'access' => array( + 'id' => 0, + 'name' => '' + ) + ), array( + 'id' => 0, + 'name' => '', + 'access' => array( + 'id' => 0, + 'name' => '' + ) + ) + ) +); + +$actual = $qb->api('API_GetRoleInfo', array( + 'dbid' => getenv('appid') +)); + +if(!objStrctMatch($actual, $expected)){ + throw new Exception('Mismatched API_GetRoleInfo Data Structure'); +} + +?> diff --git a/tests/API_GetUserInfo.php b/tests/API_GetUserInfo.php index a3081b5..e40d9cb 100644 --- a/tests/API_GetUserInfo.php +++ b/tests/API_GetUserInfo.php @@ -37,4 +37,4 @@ throw new Exception('Mismatched API_GetUserInfo Data Structure'); } -?> \ No newline at end of file +?> diff --git a/tests/API_GrantedDBs.php b/tests/API_GrantedDBs.php new file mode 100644 index 0000000..109fd71 --- /dev/null +++ b/tests/API_GrantedDBs.php @@ -0,0 +1,34 @@ + 'API_GrantedDBs', + 'errcode' => 0, + 'errtext' => 'No error', + 'databases' => array( + array( 'dbname' => '', 'dbid' => '' ), + array( 'dbname' => '', 'dbid' => '' ) + ) +); + +$actual = $qb->api('API_GrantedDBs'); + +if(!objStrctMatch($actual, $expected)){ + throw new Exception('Mismatched API_GrantedDBs Data Structure'); +} + +?> diff --git a/tests/API_ImportFromCSV.php b/tests/API_ImportFromCSV.php new file mode 100644 index 0000000..73859ef --- /dev/null +++ b/tests/API_ImportFromCSV.php @@ -0,0 +1,38 @@ + 'API_ImportFromCSV', + 'errcode' => 0, + 'errtext' => 'No error', + 'num_recs_input' => 0, + 'num_recs_added' => 0, + 'num_recs_updated' => 0, + 'num_recs_unchanged' => 0 +); + +$actual = $qb->api('API_ImportFromCSV', array( + 'dbid' => getenv('dbid'), + 'clist' => 3, + 'records_csv' => array( ' ' ) +)); + +if(!objStrctMatch($actual, $expected)){ + throw new Exception('Mismatched API_ImportFromCSV Data Structure'); +} + +?> diff --git a/tests/API_PurgeRecords.php b/tests/API_PurgeRecords.php new file mode 100644 index 0000000..d4593a2 --- /dev/null +++ b/tests/API_PurgeRecords.php @@ -0,0 +1,34 @@ + 'API_PurgeRecords', + 'errcode' => 0, + 'errtext' => 'No error', + 'num_records_deleted' => 0 +); + +$actual = $qb->api('API_PurgeRecords', array( + 'dbid' => getenv('dbid'), + 'query' => "{'3'.EX.''}" +)); + +if(!objStrctMatch($actual, $expected)){ + throw new Exception('Mismatched API_PurgeRecords Data Structure'); +} + +?> diff --git a/tests/API_SetDBVar.php b/tests/API_SetDBVar.php new file mode 100644 index 0000000..123387d --- /dev/null +++ b/tests/API_SetDBVar.php @@ -0,0 +1,34 @@ + 'API_SetDBVar', + 'errcode' => 0, + 'errtext' => 'No error' +); + +$actual = $qb->api('API_SetDBVar', array( + 'dbid' => getenv('appid'), + 'varname' => 'test', + 'value' => 'test' +)); + +if(!objStrctMatch($actual, $expected)){ + throw new Exception('Mismatched API_SetDBVar Data Structure'); +} + +?> diff --git a/tests/API_UserRoles.php b/tests/API_UserRoles.php new file mode 100644 index 0000000..891e271 --- /dev/null +++ b/tests/API_UserRoles.php @@ -0,0 +1,71 @@ + 'API_UserRoles', + 'errcode' => 0, + 'errtext' => 'No error', + 'users' => array( + array( + 'name' => '', + 'lastAccess' => 0, + 'lastAccessAppLocal' => '', + 'firstName' => '', + 'lastName' => '', + 'roles' => array( + array( + 'id' => 0, + 'name' => '', + 'access' => array( + 'id' => 0, + 'name' => '' + ) + ) + ), + 'type' => '', + 'id' => '' + ), array( + 'name' => '', + 'lastAccess' => 0, + 'lastAccessAppLocal' => '', + 'firstName' => '', + 'lastName' => '', + 'roles' => array( + array( + 'id' => 0, + 'name' => '', + 'access' => array( + 'id' => 0, + 'name' => '' + ) + ) + ), + 'type' => '', + 'id' => '' + ) + ) +); + +$actual = $qb->api('API_UserRoles', array( + 'dbid' => getenv('appid') +)); + +if(!objStrctMatch($actual, $expected)){ + throw new Exception('Mismatched API_UserRoles Data Structure'); +} + +?> diff --git a/tests/runAll.php b/tests/runAll.php index 957484e..ac14885 100644 --- a/tests/runAll.php +++ b/tests/runAll.php @@ -32,11 +32,11 @@ $error = false; if(!getenv('TRAVIS')){ - if(count($argv) !== 6){ + if(count($argv) !== 7){ echo implode("\n", array( 'ERROR: Incorrect CL Test Usage.', '', - "\t$ php tests\\runAll.php ", + "\t$ php tests\\runAll.php ", '', "\trealm: www", "\tusername: foo@bar.com", @@ -44,6 +44,8 @@ "\tappToken: dn23iuct88jvbcx7v9vttp2an6", "\tdbid: bkcamms4m", "\t (must be a table dbid, not an application dbid)", + "\appid: bkcamms4c", + "\t (must be a application dbid, not an table dbid)", '' )); @@ -55,6 +57,7 @@ putenv('password='.$argv[3]); putenv('appToken='.$argv[4]); putenv('dbid='.$argv[5]); + putenv('appid='.$argv[6]); } $qb = new QuickBase(array(