You are here

protected function RequestHelperTrait::post in Simple OAuth (OAuth2) & OpenID Connect 5.x

Same name and namespace in other branches
  1. 8.4 tests/src/Functional/RequestHelperTrait.php \Drupal\Tests\simple_oauth\Functional\RequestHelperTrait::post()
  2. 8.3 tests/src/Functional/RequestHelperTrait.php \Drupal\Tests\simple_oauth\Functional\RequestHelperTrait::post()

POST a request.

The base methods do not provide a non-form submission POST method.

Parameters

\Drupal\Core\Url $url: The URL.

array $data: The data to send.

array $options: Optional options to pass to client.

Return value

\Psr\Http\Message\ResponseInterface The response.

See also

https://www.drupal.org/project/drupal/issues/2908589#comment-12258839

13 calls to RequestHelperTrait::post()
AuthCodeFunctionalTest::postGrantedCodeWithScopes in tests/src/Functional/AuthCodeFunctionalTest.php
Posts the code and requests access to the scopes.
AuthCodeFunctionalTest::testClientAuthCodeGrantWithPkce in tests/src/Functional/AuthCodeFunctionalTest.php
Test the AuthCode grant with PKCE.
ClientCredentialsFunctionalTest::testClientCredentialsGrant in tests/src/Functional/ClientCredentialsFunctionalTest.php
Test the valid ClientCredentials grant.
ClientCredentialsFunctionalTest::testInvalidClientCredentialsGrant in tests/src/Functional/ClientCredentialsFunctionalTest.php
Test invalid ClientCredentials grant.
ClientCredentialsFunctionalTest::testMissingClientCredentialsGrant in tests/src/Functional/ClientCredentialsFunctionalTest.php
Test invalid ClientCredentials grant.

... See full list

File

tests/src/Functional/RequestHelperTrait.php, line 30

Class

RequestHelperTrait

Namespace

Drupal\Tests\simple_oauth\Functional

Code

protected function post(Url $url, array $data, array $options = []) {
  $post_url = $this
    ->getAbsoluteUrl($url
    ->toString());
  $session = $this
    ->getSession();
  $session
    ->setCookie('SIMPLETEST_USER_AGENT', drupal_generate_test_ua($this->databasePrefix));
  return $this
    ->getHttpClient()
    ->request('POST', $post_url, [
    'form_params' => $data,
    'http_errors' => FALSE,
  ] + $options);
}