recordResponse tests (just a few)
Fix a bug where if a section is terminal, and has no questions, it did not return the terminal flag as true. A little recordResponse POD.
This commit is contained in:
parent
aafd5e5a2e
commit
aa04599aec
2 changed files with 36 additions and 3 deletions
|
|
@ -297,7 +297,15 @@ sub currentSection {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 recordResponses
|
||||
=head2 recordResponses ($session, $responses)
|
||||
|
||||
=head3 $session
|
||||
|
||||
A WebGUI session object
|
||||
|
||||
=head3 $responses
|
||||
|
||||
A hash ref. More news at 6 o'clock.
|
||||
|
||||
=cut
|
||||
|
||||
|
|
@ -337,7 +345,7 @@ sub recordResponses {
|
|||
#There were no questions in the section just displayed, so increment the lastResponse by one
|
||||
if ( ref $questions ne 'ARRAY' ) {
|
||||
$self->lastResponse( $self->lastResponse + 1 );
|
||||
return [ $terminal, $terminalUrl ];
|
||||
return [ $sterminal, $terminalUrl ];
|
||||
}
|
||||
|
||||
for my $question (@$questions) {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ my $session = WebGUI::Test->session;
|
|||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
my $tests = 41;
|
||||
my $tests = 44;
|
||||
plan tests => $tests + 1;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
|
@ -319,6 +319,31 @@ is($rJSON->lastResponse(), 0, 'goto: works on existing question');
|
|||
$rJSON->goto('goto 3-0');
|
||||
is($rJSON->lastResponse(), 5, 'goto: finds first if there are duplicates');
|
||||
|
||||
####################################################
|
||||
#
|
||||
# recordResponses
|
||||
#
|
||||
####################################################
|
||||
|
||||
$rJSON->lastResponse(4);
|
||||
my $terminals;
|
||||
cmp_deeply(
|
||||
$rJSON->recordResponses($session, {}),
|
||||
[ 0, undef ],
|
||||
'recordResponses, if section has no questions, returns terminal info in the section. With no terminal info, returns [0, undef]',
|
||||
);
|
||||
is($rJSON->lastResponse(), 5, 'recordResponses, increments lastResponse if there are no questions in the section');
|
||||
|
||||
$rJSON->survey->section([2])->{terminal} = 1;
|
||||
$rJSON->survey->section([2])->{terminalUrl} = '/terminal';
|
||||
|
||||
$rJSON->lastResponse(4);
|
||||
cmp_deeply(
|
||||
$rJSON->recordResponses($session, {}),
|
||||
[ 1, '/terminal' ],
|
||||
'recordResponses, if section has no questions, returns terminal info in the section.',
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
####################################################
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue