save any defined stemmata in GraphML
[scpubgit/stemmatology.git] / t / text_tradition_parser_self.t
index 997b5ec..0a1ec10 100644 (file)
@@ -20,12 +20,37 @@ my $t = Text::Tradition->new(
     'file'  => $tradition,
     );
 
-is( ref( $t ), 'Text::Tradition', "Parsed our own GraphML" );
+is( ref( $t ), 'Text::Tradition', "Parsed GraphML version 2" );
 if( $t ) {
     is( scalar $t->collation->readings, 319, "Collation has all readings" );
     is( scalar $t->collation->paths, 376, "Collation has all paths" );
     is( scalar $t->witnesses, 13, "Collation has all witnesses" );
 }
+
+# TODO add a relationship, add a stemma, write graphml, reparse it, check that 
+# the new data is there
+$t->language('Greek');
+$t->add_stemma( 'dotfile' => 't/data/florilegium.dot' );
+$t->collation->add_relationship( 'w12', 'w13', 
+       { 'type' => 'grammatical', 'scope' => 'global', 
+         'annotation' => 'This is some note' } );
+ok( $t->collation->get_relationship( 'w12', 'w13' ), "Relationship set" );
+my $graphml_str = $t->collation->as_graphml;
+
+my $newt = Text::Tradition->new( 'input' => 'Self', 'string' => $graphml_str );
+is( ref( $newt ), 'Text::Tradition', "Parsed current GraphML version" );
+if( $newt ) {
+    is( scalar $newt->collation->readings, 319, "Collation has all readings" );
+    is( scalar $newt->collation->paths, 376, "Collation has all paths" );
+    is( scalar $newt->witnesses, 13, "Collation has all witnesses" );
+    is( scalar $newt->collation->relationships, 1, "Collation has added relationship" );
+    is( $newt->language, 'Greek', "Tradition has correct language setting" );
+    my $rel = $newt->collation->get_relationship( 'w12', 'w13' );
+    ok( $rel, "Found set relationship" );
+    is( $rel->annotation, 'This is some note', "Relationship has its properties" );
+    is( scalar $newt->stemmata, 1, "Tradition has its stemma" );
+    is( $newt->stemma(0)->witnesses, $t->stemma(0)->witnesses, "Stemma has correct length witness list" );
+}
 }