function CookieResourceTestTrait::getAuthenticationRequestOptions

Same name in other branches
  1. 9 core/modules/rest/tests/src/Functional/CookieResourceTestTrait.php \Drupal\Tests\rest\Functional\CookieResourceTestTrait::getAuthenticationRequestOptions()
  2. 8.9.x core/modules/rest/tests/src/Functional/CookieResourceTestTrait.php \Drupal\Tests\rest\Functional\CookieResourceTestTrait::getAuthenticationRequestOptions()
  3. 10 core/modules/rest/tests/src/Functional/CookieResourceTestTrait.php \Drupal\Tests\rest\Functional\CookieResourceTestTrait::getAuthenticationRequestOptions()
2 calls to CookieResourceTestTrait::getAuthenticationRequestOptions()
DbLogResourceTest::testWatchdog in core/modules/dblog/tests/src/Functional/DbLogResourceTest.php
Writes a log messages and retrieves it via the REST API.
UserRegistrationRestTest::createRequestOptions in core/modules/user/tests/src/Functional/UserRegistrationRestTest.php
Helper function to generate the request body.

File

core/modules/rest/tests/src/Functional/CookieResourceTestTrait.php, line 84

Class

CookieResourceTestTrait
Trait for ResourceTestBase subclasses testing $auth=cookie.

Namespace

Drupal\Tests\rest\Functional

Code

protected function getAuthenticationRequestOptions($method) {
    $request_options[RequestOptions::HEADERS]['Cookie'] = $this->sessionCookie;
    // @see https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html
    if (!in_array($method, [
        'HEAD',
        'GET',
        'OPTIONS',
        'TRACE',
    ])) {
        $request_options[RequestOptions::HEADERS]['X-CSRF-Token'] = $this->csrfToken;
    }
    return $request_options;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.