Skip to content
Browse files

Adding and modifying test to ensure query string in non GET method. i…

…nParams is ambiguious whether it should be used as body or query with POST/PUT like methods. I recommend letting inParams translate as query string, and enforce postBody use to send like data
  • Loading branch information...
1 parent d9c0d70 commit 5b878f020421333463362e8d66586a2e0a70ec36 @nicolas-rempulski nicolas-rempulski committed Nov 13, 2012
Showing with 22 additions and 7 deletions.
  1. +7 −2 tools/test/ajax/php/test2.php
  2. +15 −5 tools/test/ajax/tests/AjaxTest.js
View
9 tools/test/ajax/php/test2.php
@@ -25,9 +25,14 @@ function get() {
function post() {
$q = @$_POST['query'];
if ($q) {
- $result = array('response' => $q);
+ $result = array('response' => "post.".$q);
} else {
- $result = array('response' => file_get_contents('php://input'));
+ $q = @$_GET['query'];
+ if ($q) {
+ $result = array('response' => "query.".$q);
+ }else{
+ $result = array('response' => file_get_contents('php://input'));
+ }
}
$requested_with = @$_SERVER['HTTP_X_REQUESTED_WITH'];
if ($requested_with == 'XMLHttpRequest') {
View
20 tools/test/ajax/tests/AjaxTest.js
@@ -37,11 +37,21 @@ enyo.kind({
return inValue == "hello";
});
},
- testPostRequest: function() {
- this._testAjax({url: "php/test2.php", method: "POST"}, {query: "enyo"}, function(inValue) {
- return inValue.response == "enyo";
- });
- },
+ testPostRequestQuery: function() {
+ this._testAjax({url: "php/test2.php", method: "POST"}, {query: "enyo"}, function(inValue) {
+ return inValue.response == "query.enyo";
+ });
+ },
+ testPostRequestQueryWithPayload: function() {
+ this._testAjax({url: "php/test2.php", method: "POST", postBody:"data"}, {query: "enyo"}, function(inValue) {
+ return inValue.response == "query.enyo";
+ });
+ },
+ testPostRequestPayload: function() {
+ this._testAjax({url: "php/test2.php", method: "POST", postBody:"query=enyo"}, null, function(inValue) {
+ return inValue.response == "post.enyo";
+ });
+ },
testPutRequest: function() {
this._testAjax({url: "php/test2.php", method: "PUT"}, null, function(inValue) {
return inValue.status == "put";

0 comments on commit 5b878f0

Please sign in to comment.
Something went wrong with that request. Please try again.