function ApiRequestTrait::decorateWithXdebugCookie

Same name in other branches
  1. 11.x core/tests/Drupal/Tests/ApiRequestTrait.php \Drupal\Tests\ApiRequestTrait::decorateWithXdebugCookie()

Adds the Xdebug cookie to the request options.

Parameters

array $request_options: The request options.

Return value

array Request options updated with the Xdebug cookie if present.

1 call to ApiRequestTrait::decorateWithXdebugCookie()
ApiRequestTrait::makeApiRequest in core/tests/Drupal/Tests/ApiRequestTrait.php
Performs an HTTP request. Wraps the Guzzle HTTP client.

File

core/tests/Drupal/Tests/ApiRequestTrait.php, line 65

Class

ApiRequestTrait
Boilerplate for API Functional tests' HTTP requests.

Namespace

Drupal\Tests

Code

protected function decorateWithXdebugCookie(array $request_options) {
    $session = $this->getSession();
    $driver = $session->getDriver();
    if ($driver instanceof BrowserKitDriver) {
        $client = $driver->getClient();
        foreach ($client->getCookieJar()
            ->all() as $cookie) {
            if (isset($request_options[RequestOptions::HEADERS]['Cookie'])) {
                $request_options[RequestOptions::HEADERS]['Cookie'] .= '; ' . $cookie->getName() . '=' . $cookie->getValue();
            }
            else {
                $request_options[RequestOptions::HEADERS]['Cookie'] = $cookie->getName() . '=' . $cookie->getValue();
            }
        }
    }
    return $request_options;
}

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