3 use Test::More tests => 34;
11 my $attribute = "squelch-$runid";
13 ok(require RT::Attributes);
15 my $user = RT::User->new($RT::SystemUser);
16 ok (UNIVERSAL::isa($user, 'RT::User'));
17 my ($id,$msg) = $user->Create(Name => 'attrtest-'.$runid);
19 ok($user->id, "Created a test user");
21 ok(1, $user->Attributes->BuildSelectQuery);
22 my $attr = $user->Attributes;
23 # XXX: Order by id as some tests depend on it
24 $attr->OrderByCols({ FIELD => 'id' });
26 ok(1, $attr->BuildSelectQuery);
29 ok (UNIVERSAL::isa($attr,'RT::Attributes'), 'got the attributes object');
31 ($id, $msg) = $user->AddAttribute(Name => 'TestAttr', Content => 'The attribute has content');
33 is ($attr->Count,1, " One attr after adidng a first one");
35 my $first_attr = $user->FirstAttribute('TestAttr');
36 ok($first_attr, "got some sort of attribute");
37 isa_ok($first_attr, 'RT::Attribute');
38 is($first_attr->Content, 'The attribute has content', "got the right content back");
40 ($id, $msg) = $attr->DeleteEntry(Name => $runid);
41 ok(!$id, "Deleted non-existant entry - $msg");
42 is ($attr->Count,1, "1 attr after deleting an empty attr");
44 my @names = $attr->Names;
45 is ("@names", "TestAttr");
48 ($id, $msg) = $user->AddAttribute(Name => $runid, Content => "First");
51 my $runid_attr = $user->FirstAttribute($runid);
52 ok($runid_attr, "got some sort of attribute");
53 isa_ok($runid_attr, 'RT::Attribute');
54 is($runid_attr->Content, 'First', "got the right content back");
56 is ($attr->Count,2, " Two attrs after adding an attribute named $runid");
57 ($id, $msg) = $user->AddAttribute(Name => $runid, Content => "Second");
60 $runid_attr = $user->FirstAttribute($runid);
61 ok($runid_attr, "got some sort of attribute");
62 isa_ok($runid_attr, 'RT::Attribute');
63 is($runid_attr->Content, 'First', "got the first content back still");
65 is ($attr->Count,3, " Three attrs after adding a secondvalue to $runid");
66 ($id, $msg) = $attr->DeleteEntry(Name => $runid, Content => "First");
71 ($id, $msg) = $attr->DeleteEntry(Name => $runid, Content => "Second");
76 ok(1, $attr->BuildSelectQuery);
77 ($id, $msg) = $attr->DeleteEntry(Name => "moose");
78 ok(!$id, "Deleted non-existant entry - $msg");
81 ok(1, $attr->BuildSelectQuery);
82 @names = $attr->Names;
83 is("@names", "TestAttr");