Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
authorDaniel Calviño Sánchez <danxuliu@gmail.com>2020-12-03 15:11:19 +0300
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2020-12-07 06:32:00 +0300
commit184742e6ff1fe27ebc663dd1adff9ae87408d87d (patch)
tree0cdc9f2b8223c528a42a7bb40af26f5348925ad6 /build
parentb553b43b685f03c8a849d272fbcdd0e8189e6edb (diff)
Make possible to set body in requesttoken requests in integration tests
"sendingAToWithRequesttoken" needs to be used to test some non OCS endpoints which require the request token to be sent in the request. Now it is possible to specify the body (or, rather, additional contents beside the cookies and the request token) for those requests, as it will be needed for example to upload an avatar. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'build')
-rw-r--r--build/integration/features/bootstrap/BasicStructure.php24
1 files changed, 17 insertions, 7 deletions
diff --git a/build/integration/features/bootstrap/BasicStructure.php b/build/integration/features/bootstrap/BasicStructure.php
index 2c08d6ff033..4775a23b902 100644
--- a/build/integration/features/bootstrap/BasicStructure.php
+++ b/build/integration/features/bootstrap/BasicStructure.php
@@ -307,21 +307,31 @@ trait BasicStructure {
* @When Sending a :method to :url with requesttoken
* @param string $method
* @param string $url
+ * @param TableNode|array|null $body
*/
- public function sendingAToWithRequesttoken($method, $url) {
+ public function sendingAToWithRequesttoken($method, $url, $body = null) {
$baseUrl = substr($this->baseUrl, 0, -5);
+ $options = [
+ 'cookies' => $this->cookieJar,
+ 'headers' => [
+ 'requesttoken' => $this->requestToken
+ ],
+ ];
+
+ if ($body instanceof TableNode) {
+ $fd = $body->getRowsHash();
+ $options['form_params'] = $fd;
+ } elseif ($body) {
+ $options = array_merge($options, $body);
+ }
+
$client = new Client();
try {
$this->response = $client->request(
$method,
$baseUrl . $url,
- [
- 'cookies' => $this->cookieJar,
- 'headers' => [
- 'requesttoken' => $this->requestToken
- ]
- ]
+ $options
);
} catch (ClientException $e) {
$this->response = $e->getResponse();