Merge pull request #659 from wing328/add_php_unit_test

Bug fix for PHP client POST (model) and add more PHP test cases
This commit is contained in:
Tony Tam
2015-05-16 09:13:35 -07:00
11 changed files with 274 additions and 122 deletions

View File

@@ -94,7 +94,11 @@ class APIClient {
$headers[] = $this->headerName . ": " . $this->headerValue;
}
if ((isset($headerName['Content-Type']) and strpos($headerName['Content-Type'], "multipart/form-data") === FALSE) and (is_object($postData) or is_array($postData))) {
// form data
if ($postData and in_array('Content-Type: application/x-www-form-urlencoded', $headers)) {
$postData = http_build_query($postData);
}
else if ((is_object($postData) or is_array($postData)) and !in_array('Content-Type: multipart/form-data', $headers)) { // json model
$postData = json_encode($this->sanitizeForSerialization($postData));
}

View File

@@ -87,11 +87,9 @@ class {{classname}} {
// for model (json/xml)
if (isset($_tempBody)) {
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
}
// for HTTP post (form)
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") !== FALSE) {
$httpBody = http_build_query($formParams);
} else if (count($formParams) > 0) {
// for HTTP post (form)
$httpBody = $formParams;
}
// make the API Call

View File

@@ -1,7 +1,4 @@
<?php
// source code generated by http://restunited.com
// for any feedback/issue, please send to feedback{at}restunited.com
// load models defined for endpoints
foreach (glob(dirname(__FILE__)."/lib/models/*.php") as $filename)
{