[Bast-commits] r4630 - DBIx-Class-Tree-NestedSet/t

rafl at dev.catalyst.perl.org rafl at dev.catalyst.perl.org
Fri Jul 25 01:43:50 BST 2008


Author: rafl
Date: 2008-07-25 01:43:50 +0100 (Fri, 25 Jul 2008)
New Revision: 4630

Modified:
   DBIx-Class-Tree-NestedSet/t/basic.t
Log:
More tests.

Modified: DBIx-Class-Tree-NestedSet/t/basic.t
===================================================================
--- DBIx-Class-Tree-NestedSet/t/basic.t	2008-07-25 00:43:45 UTC (rev 4629)
+++ DBIx-Class-Tree-NestedSet/t/basic.t	2008-07-25 00:43:50 UTC (rev 4630)
@@ -1,6 +1,6 @@
 use strict;
 use warnings;
-use Test::More tests => 13;
+use Test::More tests => 20;
 use DBICx::TestDatabase;
 
 use FindBin;
@@ -14,19 +14,26 @@
 my $trees = $schema->resultset('Tree');
 isa_ok($trees, 'DBIx::Class::ResultSet');
 
-my $root_node = $trees->create({ content => 'foo' });
-isa_ok($root_node, 'DBIx::Class::Row');
+my $root = $trees->create({ content => 'foo' });
+isa_ok($root, 'DBIx::Class::Row');
 
-is($root_node->root->id, $root_node->id, 'root field gets set automatically');
-is($root_node->children->count, 0, 'no children, initially');
-is($root_node->nodes->count, 1, 'nodes include self');
+is($root->root->id, $root->id, 'root field gets set automatically');
+is($root->children->count, 0, 'no children, initially');
+is($root->nodes->count, 1, 'nodes include self');
 
-my $child_node = $root_node->add_to_children({ content => 'bar' });
-is($root_node->children->count, 1, 'now one child');
-is($root_node->nodes->count, 2, '... and two related nodes');
+my $child = $root->add_to_children({ content => 'bar' });
+is($child->root->id, $root->id, 'root set for children');
+is($child->parents->count, 1, 'child got one parent');
+is($child->parent->id, $root->id, 'parent rel works');
+is($root->children->count, 1, 'now one child');
+is($root->nodes->count, 2, '... and two related nodes');
 
-my $subchild = $child_node->add_to_children({ content => 'moo' });
-is($root_node->children->count, 2, 'root now two childs');
-is($root_node->nodes->count, 3, '... and three related nodes');
-is($child_node->children->count, 1, 'subnode has one children');
-is($child_node->nodes->count, 3, '... and three related nodes as well');
+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($child->children->count, 1, 'subnode has one children');
+is($child->nodes->count, 3, '... 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');




More information about the Bast-commits mailing list