X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=dbsrgits%2FDBIx-Class-Tree.git;a=blobdiff_plain;f=t%2Flib%2FTreeTest.pm;fp=t%2Flib%2FTreeTest.pm;h=7af89b30803d690138af2d9c2753ff679058b359;hp=0e66aa62174c524d6fbac7c3a0aac92cca2be530;hb=3c94ae56c4e2a8553d44944a111f479b0a87ff7d;hpb=5e44a0c684447c95bdc71100651789b537e9aebc diff --git a/t/lib/TreeTest.pm b/t/lib/TreeTest.pm index 0e66aa6..7af89b3 100644 --- a/t/lib/TreeTest.pm +++ b/t/lib/TreeTest.pm @@ -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 ++; } @@ -51,6 +51,11 @@ 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' ); }