Added onRegister hook

This commit is contained in:
Ingo Schommer 2013-12-16 23:48:24 +01:00
parent 356446d4cb
commit bfb6ee04c8
2 changed files with 16 additions and 7 deletions

View File

@ -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

View File

@ -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();
}
}