Flesh out the ResponseJSON test more. Add POD.

This commit is contained in:
Colin Kuskie 2008-12-10 02:25:42 +00:00
parent 869aa3e64d
commit 08bf6b5147
2 changed files with 62 additions and 1 deletions

View file

@ -11,6 +11,7 @@ use Test::Deep;
use Data::Dumper;
use WebGUI::Test; # Must use this before any other WebGUI modules
use WebGUI::Session;
use WebGUI::Asset::Wobject::Survey::SurveyJSON;
#----------------------------------------------------------------------------
# Init
@ -42,6 +43,55 @@ isa_ok($responseJSON , 'WebGUI::Asset::Wobject::Survey::ResponseJSON');
}
####################################################
#
# Utility test routines
#
####################################################
sub buildSurveyJSON {
my $session = shift;
my $sjson = WebGUI::Asset::Wobject::Survey::SurveyJSON->new(undef, $session->log);
##Build 4 sections
$sjson->newObject([]);
$sjson->newObject([]);
$sjson->newObject([]);
$sjson->newObject([]);
##Add questions to the sections
$sjson->newObject([0]);
$sjson->newObject([0]);
$sjson->newObject([0]);
$sjson->newObject([1]);
$sjson->newObject([1]);
##Section 3 has no questions
$sjson->newObject([3]);
$sjson->newObject([3]);
$sjson->newObject([3]);
##Add questions
$sjson->updateQuestionAnswers([0,0], 'Email');
$sjson->updateQuestionAnswers([0,1], 'Phone number');
$sjson->updateQuestionAnswers([0,2], 'Yes/No');
$sjson->updateQuestionAnswers([1,0], 'True/False');
$sjson->updateQuestionAnswers([1,1], 'Gender');
$sjson->updateQuestionAnswers([3,0], 'Date Range');
$sjson->updateQuestionAnswers([3,1], 'Ideology');
$sjson->updateQuestionAnswers([3,2], 'Email');
##Title the sections and questions
$sjson->section([0])->{title} = "Section 0";
$sjson->section([1])->{title} = "Section 1";
$sjson->section([2])->{title} = "Section 2";
$sjson->section([3])->{title} = "Section 3";
$sjson->question([0,0])->{title} = "Question 0-0";
$sjson->question([0,1])->{title} = "Question 0-1";
$sjson->question([0,2])->{title} = "Question 0-2";
$sjson->question([1,0])->{title} = "Question 1-0";
$sjson->question([1,1])->{title} = "Question 1-1";
$sjson->question([3,0])->{title} = "Question 3-0";
$sjson->question([3,1])->{title} = "Question 3-1";
$sjson->question([3,2])->{title} = "Question 3-2";
return $sjson;
}
#----------------------------------------------------------------------------
# Cleanup
END { }