You are here

protected function WebformRestSubmissionTest::request in Webform REST 4.x

Same name and namespace in other branches
  1. 8.2 tests/src/Functional/WebformRestSubmissionTest.php \Drupal\Tests\webform_rest\Functional\WebformRestSubmissionTest::request()

Performs a HTTP request. Wraps the Guzzle HTTP client.

Why wrap the Guzzle HTTP client? Because we want to keep the actual test code as simple as possible, and hence not require them to specify the 'http_errors = FALSE' request option, nor do we want them to have to convert Drupal Url objects to strings.

We also don't want to follow redirects automatically, to ensure these tests are able to detect when redirects are added or removed.

Parameters

string $method: HTTP method.

string $url: URL to request.

array $request_options: Request options to apply.

Return value

\Psr\Http\Message\ResponseInterface The response.

2 calls to WebformRestSubmissionTest::request()
WebformRestSubmissionTest::testWebformRestPatchSubmission in tests/src/Functional/WebformRestSubmissionTest.php
Test method PATCH submission resource.
WebformRestSubmissionTest::testWebformRestPostSubmission in tests/src/Functional/WebformRestSubmissionTest.php
Test method POST submission resource.

File

tests/src/Functional/WebformRestSubmissionTest.php, line 145

Class

WebformRestSubmissionTest
Test the webform rest endpoints for submissions.

Namespace

Drupal\Tests\webform_rest\Functional

Code

protected function request($method, $url, array $request_options = []) {
  $request_options[RequestOptions::HTTP_ERRORS] = FALSE;
  $request_options[RequestOptions::ALLOW_REDIRECTS] = FALSE;
  $request_options = $this
    ->decorateWithXdebugCookie($request_options);
  $client = $this
    ->getHttpClient();
  return $client
    ->request($method, $url, $request_options);
}