8 foreach my $class ( 'Positioned', 'PositionedAdjacencyList', 'AdjacencyList' ) {
10 my $employees = $schema->resultset('Employee::'.$class);
12 if ($employees->result_class->can('position_column')) {
16 $employees->create({ name=>'temp' });
19 $employees = $employees->search(undef,{order_by=>'position'});
20 ok( check_positions($employees), "$class: intial positions" );
24 foreach my $position (1..$employees->count()) {
26 $employee = $employees->find({ position=>$position });
27 $employee->move_previous();
28 ok( check_positions($employees), "$class: move_previous( $position )" );
30 $employee = $employees->find({ position=>$position });
31 $employee->move_next();
32 ok( check_positions($employees), "$class: move_next( $position )" );
34 $employee = $employees->find({ position=>$position });
35 $employee->move_first();
36 ok( check_positions($employees), "$class: move_first( $position )" );
38 $employee = $employees->find({ position=>$position });
39 $employee->move_last();
40 ok( check_positions($employees), "$class: move_last( $position )" );
42 foreach my $to_position (1..$employees->count()) {
43 $employee = $employees->find({ position=>$position });
44 $employee->move_to($to_position);
45 ok( check_positions($employees), "$class: move_to( $position => $to_position )" );
50 if ($employees->result_class->can('parent_column')) {
53 my $mom = $employees->create({ name=>'temp' });
55 $employees->create({ name=>'temp', parent_id=>$mom->id() });
58 my $children = $mom->children();
59 ok( ($children->count()==14), 'correct number of children' );
62 my @children = $children->all();
63 $mom = pop(@children);
64 foreach my $child (@children) {
65 $child->parent( $mom );
68 ok( ($mom->children->count() == 13), 'correct number of grandchildren' );
70 if ($employees->result_class->can('position_column')) {
71 # TODO: Test positioning within a tree.
79 my( $employees ) = @_;
81 my $expected_position = 0;
83 while (my $employee = $employees->next()) {
84 $expected_position ++;
85 if ($employee->position()!=$expected_position) {