summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoreltermann2013-06-21 12:59:39 (GMT)
committer Yuriy Gerasimov2013-06-21 12:59:39 (GMT)
commit1a735993cae46e563606ebe3d401109d25458a4e (patch)
treec5d30e2c6824d5dcac1201fae0d6c6c3e602f2b1
parent0ee42794b70482ad26fe8bf7b73555ca8257c6a0 (diff)
Issue #2020099 by eltermann | ygerasimov: Create a test for call using both 'uri' and 'body' arguments.HEAD8.x-4.x
-rw-r--r--lib/Drupal/services/Plugin/rest/resource/AnnotationResourceExample.php30
-rw-r--r--lib/Drupal/services/Tests/AnnotationResourceExampleTest.php8
2 files changed, 38 insertions, 0 deletions
diff --git a/lib/Drupal/services/Plugin/rest/resource/AnnotationResourceExample.php b/lib/Drupal/services/Plugin/rest/resource/AnnotationResourceExample.php
index eab6c00..db9ad66 100644
--- a/lib/Drupal/services/Plugin/rest/resource/AnnotationResourceExample.php
+++ b/lib/Drupal/services/Plugin/rest/resource/AnnotationResourceExample.php
@@ -55,6 +55,36 @@ class AnnotationResourceExample extends AnnotationResourceBase {
}
/**
+ * POST call with several parameters in uri and body.
+ *
+ * @ResourceMethod(
+ * httpMethod = "POST",
+ * uri = "postCallMixedArguments/{uri_arg1}/{uri_arg2}",
+ * parameters = {
+ * "body_arg1" = {
+ * "location" = "body",
+ * "description" = "First body argument of the call",
+ * },
+ * "body_arg2" = {
+ * "location" = "body",
+ * "description" = "Second body argument of the call",
+ * },
+ * "uri_arg1" = {
+ * "location" = "uri",
+ * "description" = "First uri argument of the call",
+ * },
+ * "uri_arg2" = {
+ * "location" = "uri",
+ * "description" = "Second uri argument of the call",
+ * }
+ * }
+ * )
+ */
+ public function postCallMixedArguments($arguments) {
+ return new ResourceResponse($arguments);
+ }
+
+ /**
* POST call with several parameters in body.
*
* @ResourceMethod(
diff --git a/lib/Drupal/services/Tests/AnnotationResourceExampleTest.php b/lib/Drupal/services/Tests/AnnotationResourceExampleTest.php
index c982e58..8230987 100644
--- a/lib/Drupal/services/Tests/AnnotationResourceExampleTest.php
+++ b/lib/Drupal/services/Tests/AnnotationResourceExampleTest.php
@@ -61,5 +61,13 @@ class AnnotationResourceExampleTest extends RESTTestBase {
$response = $this->httpRequest("postCallArguments", 'POST', $body, $this->defaultMimeType);
$decoded_response = drupal_json_decode($response);
$this->assertIdentical($decoded_response, $decoded_expected, 'postCallArguments response is correct');
+
+ $arg3 = $this->randomName();
+ $arg4 = $this->randomName();
+ $body = json_encode(array('body_arg1' => $arg1, 'body_arg2' => $arg2));
+ $response = $this->httpRequest("postCallMixedArguments/$arg3/$arg4", 'POST', $body, $this->defaultMimeType);
+ $decoded_response = drupal_json_decode($response);
+ $decoded_expected = array('body_arg1' => $arg1, 'body_arg2' => $arg2, 'uri_arg1' => $arg3, 'uri_arg2' => $arg4);
+ $this->assertIdentical($decoded_expected, $decoded_response, 'postCallMixedArguments response expected');
}
}