8 my $employees = $schema->resultset('Employee::Positioned');
12 $employees->create({ name=>'temp' });
14 $employees = $employees->search(undef,{order_by=>'position'});
15 ok( check_positions($employees), "$class: intial positions" );
19 foreach my $position (1..$employees->count()) {
21 $employee = $employees->find({ position=>$position });
22 $employee->move_previous();
23 ok( check_positions($employees), "$class: move_previous( $position )" );
25 $employee = $employees->find({ position=>$position });
26 $employee->move_next();
27 ok( check_positions($employees), "$class: move_next( $position )" );
29 $employee = $employees->find({ position=>$position });
30 $employee->move_first();
31 ok( check_positions($employees), "$class: move_first( $position )" );
33 $employee = $employees->find({ position=>$position });
34 $employee->move_last();
35 ok( check_positions($employees), "$class: move_last( $position )" );
37 foreach my $to_position (1..$employees->count()) {
38 $employee = $employees->find({ position=>$position });
39 $employee->move_to($to_position);
40 ok( check_positions($employees), "$class: move_to( $position => $to_position )" );
43 $employee = $employees->find({ position=>$position });
45 ok( !$employee->previous_sibling(), 'no previous sibling' );
46 ok( $employee->next_sibling(), 'next sibling' );
48 elsif ($position==$employees->count()) {
49 ok( $employee->previous_sibling(), 'previous sibling' );
50 ok( !$employee->next_sibling(), 'no next sibling' );
53 ok( $employee->previous_sibling(), 'previous sibling' );
54 ok( $employee->next_sibling(), 'next sibling' );
61 my( $employees ) = @_;
63 my $expected_position = 0;
64 while (my $employee = $employees->next()) {
65 $expected_position ++;
66 if ($employee->position()!=$expected_position) {