public function testSurveyName() { $survey = new Survey(); $survey->setSurveyName("yesno"); $survey->setDescription('stuff'); $q = new SurveyQuestion(); $q->setType(QuestionType::YesNo()); $q->setQuestion("A question"); $survey->addQuestion($q); //add another question $q2 = new SurveyQuestion(); $q2->setType(QuestionType::StarRating()); $secondQuestion = "Second question"; $q2->setQuestion($secondQuestion); $survey->addQuestion($q2); $this->surveyManager->createSurvey($survey); SurveyEntityManager::testClear(); $service = $this->newSurveyService(); $this->request['Body'] = "yesno"; $this->request['From'] = "1234"; $serviced = $service->service(); $this->assertTrue($serviced); $this->request['Body'] = "no"; $this->request['From'] = "1234"; $serviced = $service->service(); $this->assertTrue($serviced); $this->assertContains($secondQuestion, $service->getResponse()->getContent()); }
public function testDeleteQuestionFromSurvey() { $survey = new Survey(); $survey->setSurveyName("hi"); $survey->setDescription('stuff'); $qtypes = QuestionType::toArray(); $max = rand(4, 5); for ($i = 0; $i < $max; ++$i) { $q = new SurveyQuestion(); $q->setType(new QuestionType(rand(1, count($qtypes)))); $q->setQuestion("q" . $i); $survey->addQuestion($q); } $this->manager->createSurvey($survey); $toDelete = $survey->getQuestions()[rand(0, $max - 1)]; $idToDelete = $toDelete->getId(); $survey->deleteQuestion($idToDelete); $this->manager->updateSurvey($survey); $this->assertEquals($max - 1, count($survey->getQuestions())); }
public function testTagCloud() { $survey = new Survey(); $survey->setSurveyName("hi"); $survey->setDescription('stuff'); $q = new SurveyQuestion(); $q->setType(QuestionType::Text()); $q->setQuestion("Your Suggestions"); $survey->addQuestion($q); $this->manager->createSurvey($survey); $max = rand(1, 20); for ($i = 0; $i < $max; ++$i) { $val = $this->getRandomString(); $ans = new SurveyAnswer(); $ans->setAnswer($val); $ans->setAnsweredBy("+12064122496"); $this->manager->addAnswer($q->getId(), $ans); } $answers = $this->manager->getAnswers($survey->getId()); $strArr = ReportChartFormatter::getChartData($answers->getAnswers($q->getId()), ChartFormats::TagCloud()); $this->assertNotNull($strArr); //TODO: how the heck do i test this? I guess that it just works? }