working fuller analysis plus tests
[scpubgit/stemmatology.git] / t / graph.t
index d379d5d..f580465 100644 (file)
--- a/t/graph.t
+++ b/t/graph.t
@@ -3,10 +3,14 @@
 use strict; use warnings;
 use Test::More;
 use lib 'lib';
+use File::Which;
 use Text::Tradition;
 use XML::LibXML;
 use XML::LibXML::XPathContext;
 
+plan skip_all => 'Need Graphviz installed to test graphs' 
+       unless File::Which::which( 'dot' );
+
 my $datafile = 't/data/Collatex-16.xml';
 
 my $tradition = Text::Tradition->new( 
@@ -33,7 +37,7 @@ my @svg_edges = $svg_xpc->findnodes( '//svg:g[@class="edge"]' );
 is( scalar @svg_edges, 32, "Correct number of edges in the graph" );
 
 # Test svg creation for a subgraph
-my $part_svg = $parser->parse_string( $collation->svg_subgraph( 15 ) ); # start, no end
+my $part_svg = $parser->parse_string( $collation->as_svg( { from => 15 } ) ); # start, no end
 is( $part_svg->documentElement->nodeName(), 'svg', "Got an svg subgraph to end" );
 my $part_xpc = XML::LibXML::XPathContext->new( $part_svg->documentElement() );
 $part_xpc->registerNs( 'svg', 'http://www.w3.org/2000/svg' );
@@ -43,11 +47,8 @@ is( scalar( @svg_nodes ), 9,
 @svg_edges = $part_xpc->findnodes( '//svg:g[@class="edge"]' );
 is( scalar( @svg_edges ), 10,
        "Correct number of edges in the subgraph" );
-open( OUT, ">test.svg" );
-print OUT $part_svg->toString();
-close OUT;
 
-$part_svg = $parser->parse_string( $collation->svg_subgraph( 10, 13 ) ); # start, no end
+$part_svg = $parser->parse_string( $collation->as_svg( { from => 10, to => 13 } ) ); # start, no end
 is( $part_svg->documentElement->nodeName(), 'svg', "Got an svg subgraph in the middle" );
 $part_xpc = XML::LibXML::XPathContext->new( $part_svg->documentElement() );
 $part_xpc->registerNs( 'svg', 'http://www.w3.org/2000/svg' );
@@ -59,7 +60,7 @@ is( scalar( @svg_edges ), 11,
        "Correct number of edges in the subgraph" );
 
 
-$part_svg = $parser->parse_string( $collation->svg_subgraph( 0, 5 ) ); # start, no end
+$part_svg = $parser->parse_string( $collation->as_svg( { to => 5 } ) ); # start, no end
 is( $part_svg->documentElement->nodeName(), 'svg', "Got an svg subgraph from start" );
 $part_xpc = XML::LibXML::XPathContext->new( $part_svg->documentElement() );
 $part_xpc->registerNs( 'svg', 'http://www.w3.org/2000/svg' );