Beispiel #1
0
 /**
  * @param $ans
  * @param SurveyQuestion $question
  */
 function __construct($ans, SurveyQuestion $question)
 {
     switch ($question->getType()->getValue()) {
         case QuestionType::YesNo:
             $this->type = ChartFormats::Pie();
             $this->yuiType = "pie";
             break;
         case QuestionType::StarRating:
             $this->type = ChartFormats::Bar();
             $this->yuiType = "bar";
             break;
         case QuestionType::Text:
             $this->type = ChartFormats::TagCloud();
             $this->yuiType = null;
             break;
     }
     $this->data = ReportChartFormatter::getChartData($ans, $this->type);
     $this->question = $question;
 }
 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?
 }