import rt 3.8.7
[freeside.git] / rt / t / api / scrip_order.t
1 #!/usr/bin/perl -w
2
3 use strict;
4
5 use RT;
6 use RT::Test tests => 7;
7
8
9 # {{{ test scrip ordering based on description
10
11 my $scrip_queue = RT::Queue->new($RT::SystemUser);
12 my ($queue_id, $msg) = $scrip_queue->Create( Name => "ScripOrdering-$$", 
13     Description => 'Test scrip ordering by description' );
14 ok($queue_id, "Created scrip-ordering test queue? ".$msg);
15
16 my $priority_ten_scrip = RT::Scrip->new($RT::SystemUser);
17 (my $id, $msg) = $priority_ten_scrip->Create( 
18     Description => "10 set priority $$",
19     Queue => $queue_id, 
20     ScripCondition => 'On Create',
21     ScripAction => 'User Defined', 
22     CustomPrepareCode => '$RT::Logger->debug("Setting priority to 10..."); return 1;',
23     CustomCommitCode => '$self->TicketObj->SetPriority(10);',
24     Template => 'Blank',
25     Stage => 'TransactionCreate',
26 );
27 ok($id, "Created priority-10 scrip? ".$msg);
28
29 my $priority_five_scrip = RT::Scrip->new($RT::SystemUser);
30 ($id, $msg) = $priority_ten_scrip->Create( 
31     Description => "05 set priority $$",
32     Queue => $queue_id, 
33     ScripCondition => 'On Create',
34     ScripAction => 'User Defined', 
35     CustomPrepareCode => '$RT::Logger->debug("Setting priority to 5..."); return 1;',
36     CustomCommitCode => '$self->TicketObj->SetPriority(5);', 
37     Template => 'Blank',
38     Stage => 'TransactionCreate',
39 );
40 ok($id, "Created priority-5 scrip? ".$msg);
41
42 my $ticket = RT::Ticket->new($RT::SystemUser);
43 ($id, $msg) = $ticket->Create( 
44     Queue => $queue_id, 
45     Requestor => 'order@example.com',
46     Subject => "Scrip order test $$",
47 );
48 ok($ticket->id, "Created ticket? id=$id");
49
50 isnt($ticket->Priority , 0, "Ticket shouldn't be priority 0");
51 isnt($ticket->Priority , 5, "Ticket shouldn't be priority 5");
52 is  ($ticket->Priority , 10, "Ticket should be priority 10");
53
54 # }}}
55
56 1;