4 use Test::More tests => 7;
10 # {{{ test scrip ordering based on description
12 my $scrip_queue = RT::Queue->new($RT::SystemUser);
13 my ($queue_id, $msg) = $scrip_queue->Create( Name => "ScripOrdering-$$",
14 Description => 'Test scrip ordering by description' );
15 ok($queue_id, "Created scrip-ordering test queue? ".$msg);
17 my $priority_ten_scrip = RT::Scrip->new($RT::SystemUser);
18 (my $id, $msg) = $priority_ten_scrip->Create(
19 Description => "10 set priority $$",
21 ScripCondition => 'On Create',
22 ScripAction => 'User Defined',
23 CustomPrepareCode => '$RT::Logger->debug("Setting priority to 10..."); return 1;',
24 CustomCommitCode => '$self->TicketObj->SetPriority(10);',
26 Stage => 'TransactionCreate',
28 ok($id, "Created priority-10 scrip? ".$msg);
30 my $priority_five_scrip = RT::Scrip->new($RT::SystemUser);
31 ($id, $msg) = $priority_ten_scrip->Create(
32 Description => "05 set priority $$",
34 ScripCondition => 'On Create',
35 ScripAction => 'User Defined',
36 CustomPrepareCode => '$RT::Logger->debug("Setting priority to 5..."); return 1;',
37 CustomCommitCode => '$self->TicketObj->SetPriority(5);',
39 Stage => 'TransactionCreate',
41 ok($id, "Created priority-5 scrip? ".$msg);
43 my $ticket = RT::Ticket->new($RT::SystemUser);
44 ($id, $msg) = $ticket->Create(
46 Requestor => 'order@example.com',
47 Subject => "Scrip order test $$",
49 ok($ticket->id, "Created ticket? id=$id");
51 ok($ticket->Priority != 0, "Ticket shouldn't be priority 0");
52 ok($ticket->Priority != 5, "Ticket shouldn't be priority 5");
53 ok($ticket->Priority == 10, "Ticket should be priority 10");