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 testAddQuestions() { $survey = new Survey(); $survey->setSurveyName("hi"); $survey->setDescription('stuff'); $num = rand(3, 10); for ($i = 0; $i < $num; ++$i) { $q = new SurveyQuestion(); $q->setType(QuestionType::Text()); $q->setQuestion("q{$i}"); $survey->addQuestion($q); } $this->manager->createSurvey($survey); SurveyEntityManager::testClear(); $ss = $this->manager->getSurvey($survey->getId()); $this->assertEquals($ss->getId(), $survey->getId()); $this->assertNotNull($ss->getQuestions()); $this->assertEquals($num, count($ss->getQuestions())); $q = $ss->getQuestions()[$num - 1]; $this->assertNotNull($q); $this->assertEquals("q" . ($num - 1), $q->getQuestion()); $this->assertEquals(QuestionType::Text(), $q->getType()); }