4 use RT::Test nodata => 1, tests => 34;
10 my $attribute = "squelch-$runid";
12 ok(require RT::Attributes);
14 my $user = RT::User->new(RT->SystemUser);
15 ok (UNIVERSAL::isa($user, 'RT::User'));
16 my ($id,$msg) = $user->Create(Name => 'attrtest-'.$runid);
18 ok($user->id, "Created a test user");
20 ok(1, $user->Attributes->BuildSelectQuery);
21 my $attr = $user->Attributes;
22 # XXX: Order by id as some tests depend on it
23 $attr->OrderByCols({ FIELD => 'id' });
25 ok(1, $attr->BuildSelectQuery);
28 ok (UNIVERSAL::isa($attr,'RT::Attributes'), 'got the attributes object');
30 ($id, $msg) = $user->AddAttribute(Name => 'TestAttr', Content => 'The attribute has content');
32 is ($attr->Count,1, " One attr after adding a first one");
34 my $first_attr = $user->FirstAttribute('TestAttr');
35 ok($first_attr, "got some sort of attribute");
36 isa_ok($first_attr, 'RT::Attribute');
37 is($first_attr->Content, 'The attribute has content', "got the right content back");
39 ($id, $msg) = $attr->DeleteEntry(Name => $runid);
40 ok(!$id, "Deleted non-existant entry - $msg");
41 is ($attr->Count,1, "1 attr after deleting an empty attr");
43 my @names = $attr->Names;
44 is ("@names", "TestAttr");
47 ($id, $msg) = $user->AddAttribute(Name => $runid, Content => "First");
50 my $runid_attr = $user->FirstAttribute($runid);
51 ok($runid_attr, "got some sort of attribute");
52 isa_ok($runid_attr, 'RT::Attribute');
53 is($runid_attr->Content, 'First', "got the right content back");
55 is ($attr->Count,2, " Two attrs after adding an attribute named $runid");
56 ($id, $msg) = $user->AddAttribute(Name => $runid, Content => "Second");
59 $runid_attr = $user->FirstAttribute($runid);
60 ok($runid_attr, "got some sort of attribute");
61 isa_ok($runid_attr, 'RT::Attribute');
62 is($runid_attr->Content, 'First', "got the first content back still");
64 is ($attr->Count,3, " Three attrs after adding a secondvalue to $runid");
65 ($id, $msg) = $attr->DeleteEntry(Name => $runid, Content => "First");
70 ($id, $msg) = $attr->DeleteEntry(Name => $runid, Content => "Second");
75 ok(1, $attr->BuildSelectQuery);
76 ($id, $msg) = $attr->DeleteEntry(Name => "moose");
77 ok(!$id, "Deleted non-existant entry - $msg");
80 ok(1, $attr->BuildSelectQuery);
81 @names = $attr->Names;
82 is("@names", "TestAttr");