8 my $employees = $schema->resultset('Employee');
12 $employees->create({ name=>'temp' });
14 $employees = $employees->search(undef,{order_by=>'position'});
15 ok( check_rs($employees), "intial positions" );
17 hammer_rs( $employees );
21 DBICTest::Employee->grouping_column('group_id');
23 foreach my $group_id (1..3) {
25 $employees->create({ name=>'temp', group_id=>$group_id });
28 $employees = $employees->search(undef,{order_by=>'group_id,position'});
30 foreach my $group_id (1..3) {
31 my $group_employees = $employees->search({group_id=>$group_id});
32 $group_employees->all();
33 ok( check_rs($group_employees), "group intial positions" );
34 hammer_rs( $group_employees );
42 my $count = $rs->count();
43 my $position_column = $rs->result_class->position_column();
45 foreach my $position (1..$count) {
47 ($row) = $rs->search({ $position_column=>$position })->all();
48 $row->move_previous();
49 ok( check_rs($rs), "move_previous( $position )" );
51 ($row) = $rs->search({ $position_column=>$position })->all();
53 ok( check_rs($rs), "move_next( $position )" );
55 ($row) = $rs->search({ $position_column=>$position })->all();
57 ok( check_rs($rs), "move_first( $position )" );
59 ($row) = $rs->search({ $position_column=>$position })->all();
61 ok( check_rs($rs), "move_last( $position )" );
63 foreach my $to_position (1..$count) {
64 ($row) = $rs->search({ $position_column=>$position })->all();
65 $row->move_to($to_position);
66 ok( check_rs($rs), "move_to( $position => $to_position )" );
69 ($row) = $rs->search({ position=>$position })->all();
71 ok( !$row->previous_sibling(), 'no previous sibling' );
72 ok( !$row->first_sibling(), 'no first sibling' );
75 ok( $row->previous_sibling(), 'previous sibling' );
76 ok( $row->first_sibling(), 'first sibling' );
78 if ($position==$count) {
79 ok( !$row->next_sibling(), 'no next sibling' );
80 ok( !$row->last_sibling(), 'no last sibling' );
83 ok( $row->next_sibling(), 'next sibling' );
84 ok( $row->last_sibling(), 'last sibling' );
93 my $position_column = $rs->result_class->position_column();
94 my $expected_position = 0;
95 while (my $row = $rs->next()) {
96 $expected_position ++;
97 if ($row->get_column($position_column)!=$expected_position) {