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 );
19 DBICTest::Employee->grouping_column('group_id');
21 foreach my $group_id (1..3) {
23 $employees->create({ name=>'temp', group_id=>$group_id });
26 $employees = $employees->search(undef,{order_by=>'group_id,position'});
28 foreach my $group_id (1..3) {
29 my $group_employees = $employees->search({group_id=>$group_id});
30 $group_employees->all();
31 ok( check_rs($group_employees), "group intial positions" );
32 hammer_rs( $group_employees );
40 my $count = $rs->count();
41 my $position_column = $rs->result_class->position_column();
43 foreach my $position (1..$count) {
45 $row = $rs->find({ $position_column=>$position });
46 $row->move_previous();
47 ok( check_rs($rs), "move_previous( $position )" );
49 $row = $rs->find({ $position_column=>$position });
51 ok( check_rs($rs), "move_next( $position )" );
53 $row = $rs->find({ $position_column=>$position });
55 ok( check_rs($rs), "move_first( $position )" );
57 $row = $rs->find({ $position_column=>$position });
59 ok( check_rs($rs), "move_last( $position )" );
61 foreach my $to_position (1..$count) {
62 $row = $rs->find({ $position_column=>$position });
63 $row->move_to($to_position);
64 ok( check_rs($rs), "move_to( $position => $to_position )" );
67 $row = $rs->find({ position=>$position });
69 ok( !$row->previous_sibling(), 'no previous sibling' );
70 ok( !$row->first_sibling(), 'no first sibling' );
73 ok( $row->previous_sibling(), 'previous sibling' );
74 ok( $row->first_sibling(), 'first sibling' );
76 if ($position==$count) {
77 ok( !$row->next_sibling(), 'no next sibling' );
78 ok( !$row->last_sibling(), 'no last sibling' );
81 ok( $row->next_sibling(), 'next sibling' );
82 ok( $row->last_sibling(), 'last sibling' );
91 my $position_column = $rs->result_class->position_column();
92 my $expected_position = 0;
93 while (my $row = $rs->next()) {
94 $expected_position ++;
95 if ($row->get_column($position_column)!=$expected_position) {