This commit was generated by cvs2svn to compensate for changes in r4407,
[freeside.git] / rt / lib / t / regression / 13-attribute-tests.t
1
2 use Test::More tests => 24;
3 use RT;
4 RT::LoadConfig();
5 RT::Init();
6
7
8 my $runid = rand(200);
9
10 my $attribute = "squelch-$runid";
11
12 ok(require RT::Attributes);
13
14 my $user = RT::User->new($RT::SystemUser);
15 ok (UNIVERSAL::isa($user, 'RT::User'));
16 my ($id,$msg)  = $user->Create(Name => 'attrtest-'.$runid);
17 ok ($id, $msg);
18 ok($user->id, "Created a test user");
19
20 ok(1, $user->Attributes->BuildSelectQuery);
21 my $attr = $user->Attributes;
22
23 ok(1, $attr->BuildSelectQuery);
24
25
26 ok (UNIVERSAL::isa($attr,'RT::Attributes'), 'got the attributes object');
27
28 ($id, $msg) =  $user->AddAttribute(Name => 'TestAttr', Content => 'The attribute has content'); 
29 ok ($id, $msg);
30 is ($attr->Count,1, " One attr after adidng a first one");
31 ($id, $msg) = $attr->DeleteEntry(Name => $runid);
32 ok(!$id, "Deleted non-existant entry  - $msg");
33 is ($attr->Count,1, "1 attr after deleting an empty attr");
34
35 my @names = $attr->Names;
36 is ("@names", "TestAttr");
37
38
39 ($id, $msg) = $user->AddAttribute(Name => $runid, Content => "First");
40
41 is ($attr->Count,2, " Two attrs after adding an attribute named $runid");
42 ($id, $msg) = $user->AddAttribute(Name => $runid, Content => "Second");
43 ok($id, $msg);
44
45 is ($attr->Count,3, " Three attrs after adding a secondvalue to $runid");
46 ($id, $msg) = $attr->DeleteEntry(Name => $runid, Content => "First");
47 ok($id, $msg);
48 is ($attr->Count,2);
49
50 #$attr->_DoSearch();
51 ($id, $msg) = $attr->DeleteEntry(Name => $runid, Content => "Second");
52 ok($id, $msg);
53 is ($attr->Count,1);
54
55 #$attr->_DoSearch();
56 ok(1, $attr->BuildSelectQuery);
57 ($id, $msg) = $attr->DeleteEntry(Name => "moose");
58 ok(!$id, "Deleted non-existant entry - $msg");
59 is ($attr->Count,1);
60
61 ok(1, $attr->BuildSelectQuery);
62 @names = $attr->Names;
63 is("@names", "TestAttr");
64
65
66
67 1;