/** * 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; }
public function testGetSurveyByName() { $name = "hello there"; $s = new Survey(); $s->setDescription("a survey"); $s->setSurveyName($name); $s->setThankYouMessage("A wonder world!"); $id = $this->manager->createSurvey($s); $ss = $this->manager->getSurveyByName($name); $this->assertNotNull($ss, "Test valid retrieval by survey name='{$name}'"); $this->assertEquals($id, $ss->getId()); }