[Bast-commits] r4635 - DBIx-Class-Tree-NestedSet/t
rafl at dev.catalyst.perl.org
rafl at dev.catalyst.perl.org
Fri Jul 25 01:44:20 BST 2008
Author: rafl
Date: 2008-07-25 01:44:19 +0100 (Fri, 25 Jul 2008)
New Revision: 4635
Modified:
DBIx-Class-Tree-NestedSet/t/basic.t
Log:
Test ordering of children and parents.
Modified: DBIx-Class-Tree-NestedSet/t/basic.t
===================================================================
--- DBIx-Class-Tree-NestedSet/t/basic.t 2008-07-25 00:44:13 UTC (rev 4634)
+++ DBIx-Class-Tree-NestedSet/t/basic.t 2008-07-25 00:44:19 UTC (rev 4635)
@@ -1,6 +1,6 @@
use strict;
use warnings;
-use Test::More tests => 20;
+use Test::More tests => 22;
use DBICx::TestDatabase;
use FindBin;
@@ -28,12 +28,26 @@
is($root->children->count, 1, 'now one child');
is($root->nodes->count, 2, '... and two related nodes');
+my $child2 = $root->add_to_children({ content => 'kooh' });
+
my $subchild = $child->add_to_children({ content => 'moo' });
is($subchild->root->id, $root->id, 'root set for subchilds');
-is($root->children->count, 2, 'root now two childs');
-is($root->nodes->count, 3, '... and three related nodes');
+is($root->children->count, 3, 'root now two childs');
+is($root->nodes->count, 4, '... and three related nodes');
is($child->children->count, 1, 'subnode has one children');
-is($child->nodes->count, 3, '... and three related nodes as well');
+is($child->nodes->count, 4, '... and three related nodes as well');
is($subchild->children->count, 0, 'subchild does not have children yet');
is($subchild->parents->count, 2, '... but two parents');
is($subchild->parent->id, $child->id, 'direct parent is correct');
+
+is_deeply(
+ [map { $_->id } $subchild->parents],
+ [map { $_->id } $child, $root],
+ 'parents are ordered correctly',
+);
+
+is_deeply(
+ [map { $_->id } $root->children],
+ [map { $_->id } $child, $subchild, $child2],
+ 'roots children are ordered correctly',
+);
More information about the Bast-commits
mailing list