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