Exemplo n.º 1
0
 /**
  * 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;
 }
Exemplo n.º 2
0
 public function testExpiration()
 {
     $s = new SurveyState(time() - 500);
     $this->assertTrue($s->isExpired(10));
     $s = new SurveyState(time());
     $this->assertTrue($s->isExpired(1000));
     $s = new SurveyState(time() - 500);
     $s->setSurveyExecutionState(SurveyExecutionState::InProgress());
     $this->assertTrue($s->isExpired(10));
     $s = new SurveyState(time());
     $s->setSurveyExecutionState(SurveyExecutionState::InProgress());
     $this->assertFalse($s->isExpired(1000));
 }