Delete basicrels tests. Modify run tests to use new syntax. Remove helperrels test...
[dbsrgits/DBIx-Class.git] / t / run / 27ordered.tl
index 3883c05..7a4847e 100644 (file)
@@ -1,39 +1,40 @@
 # vim: filetype=perl
+use strict;
+use warnings;  
 
-sub run_tests {
+use Test::More;
+use lib qw(t/lib);
+use DBICTest;
 
-    plan tests => 66;
-    my $schema = shift;
+my $schema = DBICTest::init_schema();
 
-    my $employees = $schema->resultset('Employee');
-    $employees->delete();
+plan tests => 321;
 
-    foreach (1..5) {
-        $employees->create({ name=>'temp' });
-    }
-    $employees = $employees->search(undef,{order_by=>'position'});
-    ok( check_rs($employees), "intial positions" );
-
-    hammer_rs( $employees );
+my $employees = $schema->resultset('Employee');
+$employees->delete();
 
-    return;
+foreach (1..5) {
+    $employees->create({ name=>'temp' });
+}
+$employees = $employees->search(undef,{order_by=>'position'});
+ok( check_rs($employees), "intial positions" );
 
-    DBICTest::Employee->grouping_column('group_id');
-    $employees->delete();
-    foreach my $group_id (1..3) {
-        foreach (1..6) {
-            $employees->create({ name=>'temp', group_id=>$group_id });
-        }
-    }
-    $employees = $employees->search(undef,{order_by=>'group_id,position'});
+hammer_rs( $employees );
 
-    foreach my $group_id (1..3) {
-        my $group_employees = $employees->search({group_id=>$group_id});
-        $group_employees->all();
-        ok( check_rs($group_employees), "group intial positions" );
-        hammer_rs( $group_employees );
+DBICTest::Employee->grouping_column('group_id');
+$employees->delete();
+foreach my $group_id (1..3) {
+    foreach (1..6) {
+        $employees->create({ name=>'temp', group_id=>$group_id });
     }
+}
+$employees = $employees->search(undef,{order_by=>'group_id,position'});
 
+foreach my $group_id (1..3) {
+    my $group_employees = $employees->search({group_id=>$group_id});
+    $group_employees->all();
+    ok( check_rs($group_employees), "group intial positions" );
+    hammer_rs( $group_employees );
 }
 
 sub hammer_rs {
@@ -44,29 +45,29 @@ sub hammer_rs {
 
     foreach my $position (1..$count) {
 
-        $row = $rs->find({ $position_column=>$position });
+        ($row) = $rs->search({ $position_column=>$position })->all();
         $row->move_previous();
         ok( check_rs($rs), "move_previous( $position )" );
 
-        $row = $rs->find({ $position_column=>$position });
+        ($row) = $rs->search({ $position_column=>$position })->all();
         $row->move_next();
         ok( check_rs($rs), "move_next( $position )" );
 
-        $row = $rs->find({ $position_column=>$position });
+        ($row) = $rs->search({ $position_column=>$position })->all();
         $row->move_first();
         ok( check_rs($rs), "move_first( $position )" );
 
-        $row = $rs->find({ $position_column=>$position });
+        ($row) = $rs->search({ $position_column=>$position })->all();
         $row->move_last();
         ok( check_rs($rs), "move_last( $position )" );
 
         foreach my $to_position (1..$count) {
-            $row = $rs->find({ $position_column=>$position });
+            ($row) = $rs->search({ $position_column=>$position })->all();
             $row->move_to($to_position);
             ok( check_rs($rs), "move_to( $position => $to_position )" );
         }
 
-        $row = $rs->find({ position=>$position });
+        ($row) = $rs->search({ position=>$position })->all();
         if ($position==1) {
             ok( !$row->previous_sibling(), 'no previous sibling' );
             ok( !$row->first_sibling(), 'no first sibling' );
@@ -101,4 +102,3 @@ sub check_rs {
     return 1;
 }
 
-1;