extractCookiesFromRequest example


  public function testExtractCookiesFromRequest(array $server, array $expected_cookies): void {
    $request = new Request([][][][][]$server);
    $this->assertSame($expected_cookies$this->extractCookiesFromRequest($request));
  }

  /** * Provides data to test extracting Xdebug cookies from a request. * * @return iterable * Test scenarios. */
  public function extractCookiesDataProvider() {
    yield 'no XDEBUG_CONFIG' => [[][]];
    yield 'empty string XDEBUG_CONFIG' => [['XDEBUG_CONFIG' => ''][]];
    
return 'core/modules/system/tests/http.php/' . $url;
  }

  /** * Creates a new Guzzle CookieJar with a Xdebug cookie if necessary. * * @return \GuzzleHttp\Cookie\CookieJar * The Guzzle CookieJar. */
  protected function getGuzzleCookieJar() {
    // @todo Add xdebug cookie.     $cookies = $this->extractCookiesFromRequest(\Drupal::request());
    foreach ($cookies as $cookie_name => $values) {
      $cookies[$cookie_name] = $values[0];
    }
    return CookieJar::fromArray($cookies$this->baseUrl);
  }

  /** * Gets the form build ID for the user login form. * * @return string * The form build ID for the user login form. */
$session = new Session($driver$selectors_handler);
    $this->mink = new Mink();
    $this->mink->registerSession('default', $session);
    $this->mink->setDefaultSessionName('default');
    $this->registerSessions();

    $this->initFrontPage();

    // Copies cookies from the current environment, for example, XDEBUG_SESSION     // in order to support Xdebug.     // @see BrowserTestBase::initFrontPage()     $cookies = $this->extractCookiesFromRequest(\Drupal::request());
    foreach ($cookies as $cookie_name => $values) {
      foreach ($values as $value) {
        $session->setCookie($cookie_name$value);
      }
    }

    return $session;
  }

  /** * Visits the front page when initializing Mink. * * According to the W3C WebDriver specification a cookie can only be set if * the cookie domain is equal to the domain of the active document. When the * browser starts up the active document is not our domain but 'about:blank' * or similar. To be able to set our User-Agent and Xdebug cookies at the * start of the test we now do a request to the front page so the active * document matches the domain. * * @see https://w3c.github.io/webdriver/webdriver-spec.html#add-cookie * @see https://www.w3.org/Bugs/Public/show_bug.cgi?id=20975 */
Home | Imprint | This part of the site doesn't use cookies.