small docpatch (nebulous)
[dbsrgits/DBIx-Class-Tree.git] / t / lib / TreeTest.pm
index d7228ff..7af89b3 100644 (file)
@@ -9,7 +9,7 @@ use TreeTest::Schema;
 our $NODE_COUNT = 80;
 
 sub count_tests {
-    my $count = 14;
+    my $count = 17;
     if( TreeTest::Schema::Node->can('position_column') ){
         $count ++;
     }
@@ -29,11 +29,6 @@ sub run_tests {
         $node->parent( $parent_id );
     }
 
-    lives_and ( sub {
-      warn "BEGIN!!!!!\n\n";
-      is( $nodes->find(3)->copy({name => 'special'})->name,'special','copy test');
-    }, 'copy does not throw');
-
     ok( ($nodes->count()==81), 'correct number of nodes in random tree' );
     ok( ($nodes->find(3)->children->count()==7), 'node 3 has correct number of children' );
     ok( ($nodes->find(22)->children->count()==3), 'node 22 has correct number of children' );
@@ -56,9 +51,18 @@ sub run_tests {
     ok( ($nodes->find(22)->parents->count()==1), 'node 22 has correct number of parents' );
     ok( (($nodes->find(22)->parents->all())[0]->id()==$nodes->find(22)->parent->id()), 'node 22 parent matches parents' );
 
+    my @ancestors = $nodes->find(44)->ancestors();
+    ok( scalar(@ancestors)==8, 'node 44 has correct number of ancestors' );
+    ok( $ancestors[0]->id == $nodes->find(44)->parent_id, 'node 44\'s first ancestor is its parent' );
+    ok( $ancestors[-1]->name eq 'root', 'node 44\'s last ancestor is root' );
+
     if( TreeTest::Schema::Node->can('position_column') ){
         ok( check_positions(scalar $root->children()), 'positions are correct' );
     }
+
+    lives_and ( sub {
+      is( $nodes->find(3)->copy({name => 'special'})->name,'special','copy test');
+    }, 'copy does not throw');
 }
 
 sub check_positions {