mirror of
https://github.com/silverstripe/silverstripe-testsession
synced 2024-10-22 14:06:00 +02:00
Allow "global" test sessions
This commit is contained in:
parent
1582e74d10
commit
bb9994ddca
@ -67,6 +67,8 @@ on "dev/testsession/start":
|
||||
* `mailer`: Subclass of `Mailer`, typically used to record emails instead of actually sending them.
|
||||
* `datetime`: Sets a simulated date used for all framework operations.
|
||||
Format as "yyyy-MM-dd HH:mm:ss" (Example: "2012-12-31 18:40:59").
|
||||
* `globalTestSession`: Activate test session independently of the current browser session,
|
||||
effectively setting the site into test session mode for all users. Only available in "dev" mode.
|
||||
|
||||
Example usage with parameters:
|
||||
|
||||
|
@ -68,9 +68,13 @@ class TestSessionController extends Controller {
|
||||
public function start() {
|
||||
$params = $this->request->requestVars();
|
||||
|
||||
$generator = Injector::inst()->get('RandomGenerator');
|
||||
$id = substr($generator->randomToken(), 0, 10);
|
||||
Session::set('TestSessionId', $id);
|
||||
if(!empty($params['globalTestSession'])) {
|
||||
$id = null;
|
||||
} else {
|
||||
$generator = Injector::inst()->get('RandomGenerator');
|
||||
$id = substr($generator->randomToken(), 0, 10);
|
||||
Session::set('TestSessionId', $id);
|
||||
}
|
||||
|
||||
// Convert datetime from form object into a single string
|
||||
$params = $this->fixDatetimeFormField($params);
|
||||
@ -145,6 +149,12 @@ class TestSessionController extends Controller {
|
||||
->setEmptyString('Empty database');
|
||||
}
|
||||
$fields->push(new CheckboxField('requireDefaultRecords', 'Create default data?'));
|
||||
if(Director::isDev()) {
|
||||
$fields->push(
|
||||
CheckboxField::create('globalTestSession', 'Use global test session?')
|
||||
->setDescription('Caution: Will apply to all users across browsers')
|
||||
);
|
||||
}
|
||||
$fields->merge($this->getBaseFields());
|
||||
$form = new Form(
|
||||
$this,
|
||||
|
Loading…
Reference in New Issue
Block a user