You are here

protected function LTIAuthTest::decorateWithXdebugCookie in LTI Tool Provider 8

Same name and namespace in other branches
  1. 2.x tests/src/Functional/LTIAuthTest.php \Drupal\Tests\lti_tool_provider\Functional\LTIAuthTest::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 LTIAuthTest::decorateWithXdebugCookie()
LTIAuthTest::request in tests/src/Functional/LTIAuthTest.php
Performs a HTTP request. Wraps the Guzzle HTTP client.

File

tests/src/Functional/LTIAuthTest.php, line 423

Class

LTIAuthTest
Functional tests for LTI authentication.

Namespace

Drupal\Tests\lti_tool_provider\Functional

Code

protected function decorateWithXdebugCookie(array $request_options) : array {
  $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;
}