diff options
Diffstat (limited to 'rt/lib/t/regression/24pawsort.t')
-rw-r--r-- | rt/lib/t/regression/24pawsort.t | 104 |
1 files changed, 0 insertions, 104 deletions
diff --git a/rt/lib/t/regression/24pawsort.t b/rt/lib/t/regression/24pawsort.t deleted file mode 100644 index 665c325a6..000000000 --- a/rt/lib/t/regression/24pawsort.t +++ /dev/null @@ -1,104 +0,0 @@ -#!/usr/bin/perl - -use Test::More qw/no_plan/; -use RT; -RT::LoadConfig(); -RT::Init(); - -use strict; -use warnings; - -use RT::Tickets; -use RT::Queue; -use RT::CustomField; - -my($ret,$msg); - -# Test Paw Sort - - - -# ---- Create a queue to test with. -my $queue = "PAWSortQueue-$$"; -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 users - -my $me = RT::User->new($RT::SystemUser); -($ret, $msg) = $me->Create(Name => "Me$$", EmailAddress => $$.'create-me-1@example.com'); -($ret, $msg) = $me->PrincipalObj->GrantRight(Object =>$queue_obj, Right => 'OwnTicket'); -($ret, $msg) = $me->PrincipalObj->GrantRight(Object =>$queue_obj, Right => 'SeeQueue'); -($ret, $msg) = $me->PrincipalObj->GrantRight(Object =>$queue_obj, Right => 'ShowTicket'); -my $you = RT::User->new($RT::SystemUser); -($ret, $msg) = $you->Create(Name => "You$$", EmailAddress => $$.'create-you-1@example.com'); -($ret, $msg) = $you->PrincipalObj->GrantRight(Object =>$queue_obj, Right => 'OwnTicket'); -($ret, $msg) = $you->PrincipalObj->GrantRight(Object =>$queue_obj, Right => 'SeeQueue'); -($ret, $msg) = $you->PrincipalObj->GrantRight(Object =>$queue_obj, Right => 'ShowTicket'); - -my $nobody = RT::User->new($RT::SystemUser); -$nobody->Load('nobody'); - - -# ----- Create some tickets to test with. Assign them some values to -# make it easy to sort with. - -my @tickets = ( - [qw[1 10], $me], - [qw[2 20], $me], - [qw[3 20], $you], - [qw[4 30], $you], - [qw[5 5], $nobody], - [qw[6 55], $nobody], - ); -for (@tickets) { - my $t = RT::Ticket->new($RT::SystemUser); - $t->Create( Queue => $queue_obj->Id, - Subject => $_->[0], - Owner => $_->[2]->Id, - Priority => $_->[1], - ); -} - -sub check_order { - my ($tx, @order) = @_; - my @results; - while (my $t = $tx->Next) { - push @results, $t->Subject; - } - my $results = join (" ",@results); - my $order = join(" ",@order); - is( $results, $order ); -} - - -# The real tests start here - -my $cme = new RT::CurrentUser( $me ); -my $metx = new RT::Tickets( $cme ); -# Make sure we can sort in both directions on a queue specific field. -$metx->FromSQL(qq[queue="$queue"] ); -$metx->OrderBy( FIELD => "Custom.Ownership", ORDER => 'ASC' ); -is($metx->Count,6); -check_order( $metx, qw[2 1 6 5 4 3]); - -$metx->OrderBy( FIELD => "Custom.Ownership", ORDER => 'DESC' ); -is($metx->Count,6); -check_order( $metx, reverse qw[2 1 6 5 4 3]); - - - -my $cyou = new RT::CurrentUser( $you ); -my $youtx = new RT::Tickets( $cyou ); -# Make sure we can sort in both directions on a queue specific field. -$youtx->FromSQL(qq[queue="$queue"] ); -$youtx->OrderBy( FIELD => "Custom.Ownership", ORDER => 'ASC' ); -is($youtx->Count,6); -check_order( $youtx, qw[4 3 6 5 2 1]); - -__END__ - - |