RT 4.2.11, ticket#13852
[freeside.git] / rt / t / api / queue.t
1
2 use strict;
3 use warnings;
4 use RT;
5 use RT::Test nodata => 1, tests => undef;
6
7
8 {
9
10 use RT::Queue;
11
12
13 }
14
15 {
16
17 my $q = RT::Queue->new(RT->SystemUser);
18 is($q->IsValidStatus('new'), 1, 'New is a valid status');
19 is($q->IsValidStatus('f00'), 0, 'f00 is not a valid status');
20
21
22 }
23
24 {
25
26 my $q = RT::Queue->new(RT->SystemUser);
27 is($q->IsActiveStatus('new'), 1, 'New is a Active status');
28 is($q->IsActiveStatus('rejected'), 0, 'Rejected is an inactive status');
29 is($q->IsActiveStatus('f00'), 0, 'f00 is not a Active status');
30
31
32 }
33
34 {
35
36 my $q = RT::Queue->new(RT->SystemUser);
37 is($q->IsInactiveStatus('new'), 0, 'New is a Active status');
38 is($q->IsInactiveStatus('rejected'), 1, 'rejeected is an Inactive status');
39 is($q->IsInactiveStatus('f00'), 0, 'f00 is not a Active status');
40
41
42 }
43
44 {
45
46 my $queue = RT::Queue->new(RT->SystemUser);
47 my ($id, $val) = $queue->Create( Name => 'Test1');
48 ok($id, $val);
49
50 ($id, $val) = $queue->Create( Name => '66');
51 ok(!$id, $val);
52
53
54 }
55
56 {
57
58 my $Queue = RT::Queue->new(RT->SystemUser);
59 my ($id, $msg) = $Queue->Create(Name => "Foo");
60 ok ($id, "Foo $id was created");
61 ok(my $group = $Queue->RoleGroup('Requestor'));
62 ok ($group->Id, "Found the requestors object for this Queue");
63
64 {
65     my ($status, $msg) = $Queue->AddWatcher(Type => 'Cc', Email => 'bob@fsck.com');
66     ok ($status, "Added bob at fsck.com as a requestor") or diag "error: $msg";
67 }
68
69 ok(my $bob = RT::User->new(RT->SystemUser), "Creating a bob rt::user");
70 $bob->LoadByEmail('bob@fsck.com');
71 ok($bob->Id,  "Found the bob rt user");
72 ok ($Queue->IsWatcher(Type => 'Cc', PrincipalId => $bob->PrincipalId), "The Queue actually has bob at fsck.com as a requestor");
73
74 {
75     my ($status, $msg) = $Queue->DeleteWatcher(Type =>'Cc', Email => 'bob@fsck.com');
76     ok ($status, "Deleted bob from Ccs") or diag "error: $msg";
77     ok (!$Queue->IsWatcher(Type => 'Cc', PrincipalId => $bob->PrincipalId),
78         "The Queue no longer has bob at fsck.com as a requestor");
79 }
80
81 $group = $Queue->RoleGroup('Cc');
82 ok ($group->Id, "Found the cc object for this Queue");
83 $group = $Queue->RoleGroup('AdminCc');
84 ok ($group->Id, "Found the AdminCc object for this Queue");
85
86
87 }
88
89 done_testing;