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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
|
use strict;
use warnings;
use RT;
use RT::Test nodata => 1, tests => undef, config => <<'CONFIG';
Set( %ServiceAgreements, (
Default => 'standard',
Levels => {
'standard' => {
Starts => { RealMinutes => 0 },
Resolve => { RealMinutes => 8*60 },
},
'urgent' => {
Starts => { RealMinutes => 0 },
Resolve => { RealMinutes => 2*60 },
},
},
));
CONFIG
{
use RT::Queue;
}
{
my $q = RT::Queue->new(RT->SystemUser);
is($q->IsValidStatus('new'), 1, 'New is a valid status');
is($q->IsValidStatus('f00'), 0, 'f00 is not a valid status');
}
{
my $q = RT::Queue->new(RT->SystemUser);
is($q->IsActiveStatus('new'), 1, 'New is a Active status');
is($q->IsActiveStatus('rejected'), 0, 'Rejected is an inactive status');
is($q->IsActiveStatus('f00'), 0, 'f00 is not a Active status');
}
{
my $q = RT::Queue->new(RT->SystemUser);
is($q->IsInactiveStatus('new'), 0, 'New is a Active status');
is($q->IsInactiveStatus('rejected'), 1, 'rejeected is an Inactive status');
is($q->IsInactiveStatus('f00'), 0, 'f00 is not a Active status');
}
{
my $queue = RT::Queue->new(RT->SystemUser);
my ($id, $val) = $queue->Create( Name => 'Test1');
ok($id, $val);
($id, $val) = $queue->Create( Name => '66');
ok(!$id, $val);
}
{
my $Queue = RT::Queue->new(RT->SystemUser);
my ($id, $msg) = $Queue->Create(Name => "Foo");
ok ($id, "Foo $id was created");
ok(my $group = $Queue->RoleGroup('Requestor'));
ok ($group->Id, "Found the requestors object for this Queue");
{
my ($status, $msg) = $Queue->AddWatcher(Type => 'Cc', Email => 'bob@fsck.com');
ok ($status, "Added bob at fsck.com as a requestor") or diag "error: $msg";
}
ok(my $bob = RT::User->new(RT->SystemUser), "Creating a bob rt::user");
$bob->LoadByEmail('bob@fsck.com');
ok($bob->Id, "Found the bob rt user");
ok ($Queue->IsWatcher(Type => 'Cc', PrincipalId => $bob->PrincipalId), "The Queue actually has bob at fsck.com as a requestor");
{
my ($status, $msg) = $Queue->DeleteWatcher(Type =>'Cc', Email => 'bob@fsck.com');
ok ($status, "Deleted bob from Ccs") or diag "error: $msg";
ok (!$Queue->IsWatcher(Type => 'Cc', PrincipalId => $bob->PrincipalId),
"The Queue no longer has bob at fsck.com as a requestor");
}
$group = $Queue->RoleGroup('Cc');
ok ($group->Id, "Found the cc object for this Queue");
$group = $Queue->RoleGroup('AdminCc');
ok ($group->Id, "Found the AdminCc object for this Queue");
}
{
my $NoSLA = RT::Queue->new(RT->SystemUser);
my ($id, $msg) = $NoSLA->Create(Name => "NoSLA");
ok($id, "created queue NoSLA");
is($NoSLA->SLA, undef, 'No SLA for NoSLA');
my $WithSLA = RT::Queue->new(RT->SystemUser);
($id, $msg) = $WithSLA->Create(Name => "WithSLA", SLA => 'urgent');
ok($id, "created queue WithSLA");
is($WithSLA->SLA, 'urgent', 'SLA is set');
$WithSLA->SetSLA('standard');
is($WithSLA->SLA, 'standard', 'SLA is updated');
}
done_testing;
|