function __construct($startTime = null) { $this->startTime = $startTime; if (is_null($this->startTime)) { $this->startTime = time(); } $this->surveyExecutionState = SurveyExecutionState::Unknown(); $this->questionIndex = null; $this->sessionId = null; }
public function testSerialization() { $s = new SurveyState(time() - 500); $serialzedValue = serialize($s); /** * @vars $state SurveyState */ $state = unserialize($serialzedValue); $this->assertTrue($state->isState(SurveyExecutionState::Unknown())); }
function testConstructor() { $this->assertFalse(array_key_exists(SurveyRequestService::SESSION_KEY, $this->session)); $manager = $this->newSurveyService(); $this->assertTrue($manager->getSurveyState()->isState(SurveyExecutionState::Unknown())); }
/** * public modifier since its used for tests * * private function. * @return bool */ public function shouldService() { //We only service this request if we are in survey mode. $body = $this->getRequestBody(); if (is_null($body)) { return false; } if (in_array(strtolower($body), array("exit", "quit", "cancel"))) { $this->reset(); return false; } if (is_string($body)) { $surveyName = strtolower($body); $survey = $this->surveyManager->getSurveyByName($surveyName); if ($survey && !is_null($survey)) { $this->reset($survey); return true; } } //Not in a valid survey if ($this->surveyState->isState(SurveyExecutionState::Unknown())) { return false; } if ($this->surveyState->isExpired(self::SURVEY_TIME_OUT)) { $this->reset(); return false; } return true; }