Update to Drupal 8.1.1. For more information, see https://www.drupal.org/node/2718713
This commit is contained in:
parent
c0a0d5a94c
commit
9eae24d844
669 changed files with 3873 additions and 1553 deletions
40
core/tests/Drupal/Tests/SessionTestTrait.php
Normal file
40
core/tests/Drupal/Tests/SessionTestTrait.php
Normal file
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* Provides methods to generate and get session name in tests.
|
||||
*/
|
||||
trait SessionTestTrait {
|
||||
|
||||
/**
|
||||
* The name of the session cookie.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $sessionName;
|
||||
|
||||
/**
|
||||
* Generates a session cookie name.
|
||||
*
|
||||
* @param string $data
|
||||
* The data to generate session name.
|
||||
*/
|
||||
protected function generateSessionName($data) {
|
||||
$prefix = (Request::createFromGlobals()->isSecure() ? 'SSESS' : 'SESS');
|
||||
$this->sessionName = $prefix . substr(hash('sha256', $data), 0, 32);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the session name in use on the child site.
|
||||
*
|
||||
* @return string
|
||||
* The name of the session cookie.
|
||||
*/
|
||||
protected function getSessionName() {
|
||||
return $this->sessionName;
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue