Added some tests for Survey visualization

This commit is contained in:
Patrick Donelan 2009-05-11 11:06:55 +00:00
parent b12906a777
commit 9e2cdeca13
2 changed files with 23 additions and 2 deletions

View file

@ -618,7 +618,11 @@ sub graph {
my $method = "as_$format";
$g->$method($path);
return $storage->getUrl($filename);
if (wantarray) {
return ( $storage, $filename);
} else {
return $storage->getUrl($filename);
}
}
#-------------------------------------------------------------------

View file

@ -18,7 +18,7 @@ my $session = WebGUI::Test->session;
#----------------------------------------------------------------------------
# Tests
my $tests = 19;
my $tests = 20;
plan tests => $tests + 1;
#----------------------------------------------------------------------------
@ -114,6 +114,23 @@ ok($s->responseId, '..(and similarly for responseId)');
}
}
eval 'use GraphViz';
SKIP: {
skip "Unable to load GraphViz", 1 if $@;
$survey->surveyJSON->remove([1]);
my ($storage, $filename) = $survey->graph( { format => 'plain', layout => 'dot' } );
like($storage->getFileContentsAsScalar($filename), qr{
^graph .* # starts with graph
(node .*){3} # ..then 3 nodes
(edge .*){3} # ..then 3 edges
stop$ # ..and end with stop
}xs, 'Generated graph looks roughly okay');
}
#----------------------------------------------------------------------------