import rt 3.8.8
[freeside.git] / rt / lib / t / regression / 25scrip_order.t
1 #!/usr/bin/perl -w
2
3 use strict;
4 use Test::More tests => 7;
5
6 use RT;
7 RT::LoadConfig();
8 RT::Init;
9
10 # {{{ test scrip ordering based on description
11
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);
16
17 my $priority_ten_scrip = RT::Scrip->new($RT::SystemUser);
18 (my $id, $msg) = $priority_ten_scrip->Create( 
19     Description => "10 set priority $$",
20     Queue => $queue_id, 
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);',
25     Template => 'Blank',
26     Stage => 'TransactionCreate',
27 );
28 ok($id, "Created priority-10 scrip? ".$msg);
29
30 my $priority_five_scrip = RT::Scrip->new($RT::SystemUser);
31 ($id, $msg) = $priority_ten_scrip->Create( 
32     Description => "05 set priority $$",
33     Queue => $queue_id, 
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);', 
38     Template => 'Blank',
39     Stage => 'TransactionCreate',
40 );
41 ok($id, "Created priority-5 scrip? ".$msg);
42
43 my $ticket = RT::Ticket->new($RT::SystemUser);
44 ($id, $msg) = $ticket->Create( 
45     Queue => $queue_id, 
46     Requestor => 'order@example.com',
47     Subject => "Scrip order test $$",
48 );
49 ok($ticket->id, "Created ticket? id=$id");
50
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");
54
55 # }}}
56
57 1;