protected function SessionHttpsTest::getPathFromLocationHeader in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/src/Tests/Session/SessionHttpsTest.php \Drupal\system\Tests\Session\SessionHttpsTest::getPathFromLocationHeader()
Extract internal path from the location header on the response.
2 calls to SessionHttpsTest::getPathFromLocationHeader()
- SessionHttpsTest::loginHttp in core/
modules/ system/ src/ Tests/ Session/ SessionHttpsTest.php - Log in a user via HTTP.
- SessionHttpsTest::loginHttps in core/
modules/ system/ src/ Tests/ Session/ SessionHttpsTest.php - Log in a user via HTTPS.
File
- core/
modules/ system/ src/ Tests/ Session/ SessionHttpsTest.php, line 187 - Contains \Drupal\system\Tests\Session\SessionHttpsTest.
Class
- SessionHttpsTest
- Ensure that when running under HTTPS two session cookies are generated.
Namespace
Drupal\system\Tests\SessionCode
protected function getPathFromLocationHeader($https = FALSE, $response_code = 303) {
// Generate the base_url.
$base_url = $this->container
->get('url_generator')
->generateFromRoute('<front>', [], [
'absolute' => TRUE,
]);
if ($https) {
$base_url = str_replace('http://', 'https://', $base_url);
}
else {
$base_url = str_replace('https://', 'http://', $base_url);
}
// The mock front controllers (http.php and https.php) add the script name
// to $_SERVER['REQEUST_URI'] and friends. Therefore it is necessary to
// strip that also.
$base_url .= 'index.php/';
// Extract relative path from location header.
$this
->assertResponse($response_code);
$location = $this
->drupalGetHeader('location');
$this
->assertIdentical(strpos($location, $base_url), 0, 'Location header contains expected base URL');
return substr($location, strlen($base_url));
}