Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 4 |
SessionTestTrait | |
0.00% |
0 / 1 |
|
0.00% |
0 / 2 |
12 | |
0.00% |
0 / 4 |
generateSessionName | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 3 |
|||
getSessionName | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
<?php | |
/** | |
* @file | |
* Contains \Drupal\simpletest\SessionTestTrait. | |
*/ | |
namespace Drupal\simpletest; | |
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; | |
} | |
} |