import rt 3.8.7
[freeside.git] / rt / t / api / queue.t
1
2 use strict;
3 use warnings;
4 use RT;
5 use RT::Test tests => 24;
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 = RT::Group->new($RT::SystemUser));
62 ok($group->LoadQueueRoleGroup(Queue => $id, Type=> 'Requestor'));
63 ok ($group->Id, "Found the requestors object for this Queue");
64
65 {
66     my ($status, $msg) = $Queue->AddWatcher(Type => 'Cc', Email => 'bob@fsck.com');
67     ok ($status, "Added bob at fsck.com as a requestor") or diag "error: $msg";
68 }
69
70 ok(my $bob = RT::User->new($RT::SystemUser), "Creating a bob rt::user");
71 $bob->LoadByEmail('bob@fsck.com');
72 ok($bob->Id,  "Found the bob rt user");
73 ok ($Queue->IsWatcher(Type => 'Cc', PrincipalId => $bob->PrincipalId), "The Queue actually has bob at fsck.com as a requestor");
74
75 {
76     my ($status, $msg) = $Queue->DeleteWatcher(Type =>'Cc', Email => 'bob@fsck.com');
77     ok ($status, "Deleted bob from Ccs") or diag "error: $msg";
78     ok (!$Queue->IsWatcher(Type => 'Cc', PrincipalId => $bob->PrincipalId),
79         "The Queue no longer has bob at fsck.com as a requestor");
80 }
81
82 $group = RT::Group->new($RT::SystemUser);
83 ok($group->LoadQueueRoleGroup(Queue => $id, Type=> 'Cc'));
84 ok ($group->Id, "Found the cc object for this Queue");
85 $group = RT::Group->new($RT::SystemUser);
86 ok($group->LoadQueueRoleGroup(Queue => $id, Type=> 'AdminCc'));
87 ok ($group->Id, "Found the AdminCc object for this Queue");
88
89
90 }
91
92 1;