[Rt-commit] r8247 - rt/branches/3.7-EXPERIMENTAL-TUNIS/t/ordered-1

ruz at bestpractical.com ruz at bestpractical.com
Sat Jul 21 05:35:08 EDT 2007


Author: ruz
Date: Sat Jul 21 05:35:04 2007
New Revision: 8247

Modified:
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/ordered-1/cf_sort.t

Log:
* we must always test ordering in both directions, it can be just luck
  that test pass

Modified: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/ordered-1/cf_sort.t
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL-TUNIS/t/ordered-1/cf_sort.t	(original)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/ordered-1/cf_sort.t	Sat Jul 21 05:35:04 2007
@@ -18,9 +18,11 @@
 
 # ---- Create a queue to test with.
 my $queue = "CFSortQueue-$$";
-my $queue_obj = RT::Queue->new($RT::SystemUser);
-($ret, $msg) = $queue_obj->Create(Name => $queue,
-                                  Description => 'queue for custom field sort testing');
+my $queue_obj = RT::Queue->new( $RT::SystemUser );
+($ret, $msg) = $queue_obj->Create(
+    Name => $queue,
+    Description => 'queue for custom field sort testing'
+);
 ok($ret, "$queue test queue creation. $msg");
 
 # ---- Create some custom fields.  We're not currently using all of
@@ -33,7 +35,7 @@
 ($ret, $msg) = $cfO->Create( Name => 'Order',
                              Queue => 0,
                              SortOrder => 1,
-                             Description => q[Something to compare results for, since we can't guarantee ticket ID],
+                             Description => q{Something to compare results for, since we can't guarantee ticket ID},
                              Type=> 'FreeformSingle');
 ok($ret, "Custom Field Order created");
 
@@ -110,10 +112,18 @@
 # in Tickets_Overlay.
 $tx = new RT::Tickets( $RT::SystemUser );
 $tx->FromSQL(qq[queue="$queue"] );
-$tx->OrderBy( FIELD => "CF.{Charlie}", ORDER => 'DES' );
+$tx->OrderBy( FIELD => "CF.{Charlie}", ORDER => 'DESC' );
+diag $tx->BuildSelectQuery;
 is($tx->Count,2);
 check_order( $tx, 1, 2);
 
+$tx = new RT::Tickets( $RT::SystemUser );
+$tx->FromSQL(qq[queue="$queue"] );
+$tx->OrderBy( FIELD => "CF.{Charlie}", ORDER => 'ASC' );
+diag $tx->BuildSelectQuery;
+is($tx->Count,2);
+check_order( $tx, 2, 1);
+
 # Add a new ticket, to test sorting on multiple columns.
 my $t3 = RT::Ticket->new($RT::SystemUser);
 $t3->Create( Queue => $queue_obj->Id,
@@ -126,18 +136,39 @@
 
 $tx = new RT::Tickets( $RT::SystemUser );
 $tx->FromSQL(qq[queue="$queue"] );
-$tx->OrderByCols({FIELD => "CF.${queue}.{Charlie}", ORDER => 'ASC'},
-                 {FIELD => "CF.${queue}.{Alpha}", ORDER => 'DES'}
-                );
+$tx->OrderByCols(
+    { FIELD => "CF.${queue}.{Charlie}", ORDER => 'ASC' },
+    { FIELD => "CF.${queue}.{Alpha}",   ORDER => 'DES' },
+);
 is($tx->Count,3);
 check_order( $tx, 3, 2, 1);
 
+$tx = new RT::Tickets( $RT::SystemUser );
+$tx->FromSQL(qq[queue="$queue"] );
+$tx->OrderByCols(
+    { FIELD => "CF.${queue}.{Charlie}", ORDER => 'DES' },
+    { FIELD => "CF.${queue}.{Alpha}",   ORDER => 'ASC' },
+);
+is($tx->Count,3);
+check_order( $tx, 1, 2, 3);
+
 # Reverse the order of the secondary column, which changes the order
 # of the first two tickets.
 $tx = new RT::Tickets( $RT::SystemUser );
 $tx->FromSQL(qq[queue="$queue"] );
-$tx->OrderByCols({FIELD => "CF.${queue}.{Charlie}", ORDER => 'ASC'},
-                 {FIELD => "CF.${queue}.{Alpha}", ORDER => 'ASC'}
-                );
+$tx->OrderByCols(
+    { FIELD => "CF.${queue}.{Charlie}", ORDER => 'ASC' },
+    { FIELD => "CF.${queue}.{Alpha}",   ORDER => 'ASC' },
+);
 is($tx->Count,3);
 check_order( $tx, 2, 3, 1);
+
+$tx = new RT::Tickets( $RT::SystemUser );
+$tx->FromSQL(qq[queue="$queue"] );
+$tx->OrderByCols(
+    { FIELD => "CF.${queue}.{Charlie}", ORDER => 'DES' },
+    { FIELD => "CF.${queue}.{Alpha}",   ORDER => 'DES' },
+);
+is($tx->Count,3);
+check_order( $tx, 1, 3, 2);
+


More information about the Rt-commit mailing list