6 use RT::Test tests => 7;
10 my $scrip_queue = RT::Queue->new(RT->SystemUser);
11 my ($queue_id, $msg) = $scrip_queue->Create( Name => "ScripOrdering-$$",
12 Description => 'Test scrip ordering by description' );
13 ok($queue_id, "Created scrip-ordering test queue? ".$msg);
15 my $priority_ten_scrip = RT::Scrip->new(RT->SystemUser);
16 (my $id, $msg) = $priority_ten_scrip->Create(
17 Description => "10 set priority $$",
19 ScripCondition => 'On Create',
20 ScripAction => 'User Defined',
21 CustomPrepareCode => '$RT::Logger->debug("Setting priority to 10..."); return 1;',
22 CustomCommitCode => '$self->TicketObj->SetPriority(10);',
24 Stage => 'TransactionCreate',
26 ok($id, "Created priority-10 scrip? ".$msg);
28 my $priority_five_scrip = RT::Scrip->new(RT->SystemUser);
29 ($id, $msg) = $priority_ten_scrip->Create(
30 Description => "05 set priority $$",
32 ScripCondition => 'On Create',
33 ScripAction => 'User Defined',
34 CustomPrepareCode => '$RT::Logger->debug("Setting priority to 5..."); return 1;',
35 CustomCommitCode => '$self->TicketObj->SetPriority(5);',
37 Stage => 'TransactionCreate',
39 ok($id, "Created priority-5 scrip? ".$msg);
41 my $ticket = RT::Ticket->new(RT->SystemUser);
42 ($id, $msg) = $ticket->Create(
44 Requestor => 'order@example.com',
45 Subject => "Scrip order test $$",
47 ok($ticket->id, "Created ticket? id=$id");
49 isnt($ticket->Priority , 0, "Ticket shouldn't be priority 0");
50 isnt($ticket->Priority , 5, "Ticket shouldn't be priority 5");
51 is ($ticket->Priority , 10, "Ticket should be priority 10");