mirror of
https://github.com/silverstripe/silverstripe-testsession
synced 2024-10-22 14:06:00 +02:00
Added onRegister hook
This commit is contained in:
parent
356446d4cb
commit
bfb6ee04c8
@ -61,4 +61,3 @@ Parameters for "dev/testsession/start":
|
||||
Example usage with parameters:
|
||||
|
||||
dev/testsession/start?database=ss_tmpdb_1234567&fixture=cms/tests/controller/CMSMainTest.yml
|
||||
|
||||
|
@ -10,6 +10,22 @@ class TestSessionMemberExtension extends DataExtension {
|
||||
public function memberLoggedIn() {
|
||||
if(!SapphireTest::using_temp_db()) return;
|
||||
|
||||
$this->setCurrentMemberState();
|
||||
}
|
||||
|
||||
public function onRegister() {
|
||||
if(!SapphireTest::using_temp_db()) return;
|
||||
|
||||
$this->setCurrentMemberState();
|
||||
}
|
||||
|
||||
public function memberLoggedOut() {
|
||||
if(!SapphireTest::using_temp_db()) return;
|
||||
|
||||
$state = TestSessionDatabaseState::get()->filter('Key', 'CurrentMemberID')->removeAll();
|
||||
}
|
||||
|
||||
protected function setCurrentMemberState() {
|
||||
$state = TestSessionDatabaseState::get()->find('Key', 'CurrentMemberID');
|
||||
if(!$state) {
|
||||
$state = new TestSessionDatabaseState(array(
|
||||
@ -20,10 +36,4 @@ class TestSessionMemberExtension extends DataExtension {
|
||||
$state->write();
|
||||
}
|
||||
|
||||
public function memberLoggedOut() {
|
||||
if(!SapphireTest::using_temp_db()) return;
|
||||
|
||||
$state = TestSessionDatabaseState::get()->filter('Key', 'CurrentMemberID')->removeAll();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user