8 my $employees = $schema->resultset('Employee::AdjacencyList');
11 my $grandma = $employees->create({ name=>'grandma', parent_id=>0 });
13 $employees->create({ name=>'temp', parent_id=>$grandma->id() });
15 ok( ($grandma->children->count()==15), 'grandma children' );
17 my $mom = ($grandma->children->search(undef,{rows=>1})->all())[0];
19 ($grandma->children->search(undef,{rows=>1})->all())[0]->parent( $mom );
21 ok( ($mom->children->count()==5), 'mom children' );
22 ok( ($grandma->children->count()==10), 'grandma children' );
24 $mom = ($grandma->children->search(undef,{rows=>2})->all())[0];
26 ($grandma->children->search(undef,{rows=>1})->all())[0]->parent( $mom );
28 ok( ($mom->children->count()==4), 'mom children' );
29 ok( ($grandma->children->count()==6), 'grandma children' );
31 ok( check_rs( scalar $grandma->children() ), 'correct positions' );
37 my $position_column = $rs->result_class->position_column();
38 my $expected_position = 0;
39 while (my $row = $rs->next()) {
40 $expected_position ++;
41 if ($row->get_column($position_column)!=$expected_position) {
44 my $children = $row->children();
45 while (my $child = $children->next()) {
46 return 0 if (!check_rs( scalar $child->children() ));