X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Flib%2FTreeTest.pm;h=e77eea1a583cbe4857662765fa6b8aacab4b4382;hb=eccca9212017ca7aae985dcf16c8de73234cac90;hp=95a0dec0baedfcca5a811e87a47aa3cb9b0597c2;hpb=8295812709d2b2fdc8dba6d448d5fa58011c4166;p=dbsrgits%2FDBIx-Class-Tree.git diff --git a/t/lib/TreeTest.pm b/t/lib/TreeTest.pm index 95a0dec..e77eea1 100644 --- a/t/lib/TreeTest.pm +++ b/t/lib/TreeTest.pm @@ -8,7 +8,11 @@ use TreeTest::Schema; our $NODE_COUNT = 80; sub count_tests { - return 11; + my $count = 13; + if( TreeTest::Schema::Node->can('position_column') ){ + $count ++; + } + return $count; } sub run_tests { @@ -41,6 +45,24 @@ sub run_tests { $nodes->find(22)->attach_sibling( $nodes->find(3) ); ok( ($nodes->find(22)->children->count()==2), 'node 22 has correct number of children' ); ok( ($nodes->find(22)->siblings->count()==3), 'node 22 has correct number of siblings' ); + + 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' ); + + if( TreeTest::Schema::Node->can('position_column') ){ + ok( check_positions(scalar $root->children()), 'positions are correct' ); + } +} + +sub check_positions { + my $nodes = shift; + my $position = 0; + while (my $node = $nodes->next()) { + $position ++; + return 0 if ($node->position() != $position); + return 0 if ( !check_positions(scalar $node->children()) ); + } + return 1; } 1;