protected function JsonApiRequestTestTrait::decorateWithXdebugCookie in Drupal 10
Same name and namespace in other branches
- 8 core/modules/jsonapi/tests/src/Functional/JsonApiRequestTestTrait.php \Drupal\Tests\jsonapi\Functional\JsonApiRequestTestTrait::decorateWithXdebugCookie()
- 9 core/modules/jsonapi/tests/src/Functional/JsonApiRequestTestTrait.php \Drupal\Tests\jsonapi\Functional\JsonApiRequestTestTrait::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.
File
- core/modules/ jsonapi/ tests/ src/ Functional/ JsonApiRequestTestTrait.php, line 57 
Class
- JsonApiRequestTestTrait
- Boilerplate for JSON:API Functional tests' HTTP requests.
Namespace
Drupal\Tests\jsonapi\FunctionalCode
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;
}