first pass RT4 merge, RT#13852
[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
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);
14
15 my $priority_ten_scrip = RT::Scrip->new(RT->SystemUser);
16 (my $id, $msg) = $priority_ten_scrip->Create( 
17     Description => "10 set priority $$",
18     Queue => $queue_id, 
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);',
23     Template => 'Blank',
24     Stage => 'TransactionCreate',
25 );
26 ok($id, "Created priority-10 scrip? ".$msg);
27
28 my $priority_five_scrip = RT::Scrip->new(RT->SystemUser);
29 ($id, $msg) = $priority_ten_scrip->Create( 
30     Description => "05 set priority $$",
31     Queue => $queue_id, 
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);', 
36     Template => 'Blank',
37     Stage => 'TransactionCreate',
38 );
39 ok($id, "Created priority-5 scrip? ".$msg);
40
41 my $ticket = RT::Ticket->new(RT->SystemUser);
42 ($id, $msg) = $ticket->Create( 
43     Queue => $queue_id, 
44     Requestor => 'order@example.com',
45     Subject => "Scrip order test $$",
46 );
47 ok($ticket->id, "Created ticket? id=$id");
48
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");
52
53