[Rt-commit] r3397 - in rt/branches/3.5-TESTING: . etc lib/RT
lib/t/regression
glasser at bestpractical.com
glasser at bestpractical.com
Wed Jul 6 09:47:12 EDT 2005
Author: glasser
Date: Wed Jul 6 09:47:11 2005
New Revision: 3397
Modified:
rt/branches/3.5-TESTING/ (props changed)
rt/branches/3.5-TESTING/etc/RT_SiteConfig.pm
rt/branches/3.5-TESTING/lib/RT/Record.pm
rt/branches/3.5-TESTING/lib/t/regression/13-attribute-tests.t
Log:
r36395 at tin-foil: glasser | 2005-07-06 10:43:15 -0300
Clarify documentation and add tests for RT::Record->FirstAttribute (suggested by Todd Chapman)
Modified: rt/branches/3.5-TESTING/etc/RT_SiteConfig.pm
==============================================================================
--- rt/branches/3.5-TESTING/etc/RT_SiteConfig.pm (original)
+++ rt/branches/3.5-TESTING/etc/RT_SiteConfig.pm Wed Jul 6 09:47:11 2005
@@ -16,4 +16,5 @@
Set( $rtname, 'example.com');
Set( $DevelMode => 1);
+Set( $WebPort, 6453 );
1;
Modified: rt/branches/3.5-TESTING/lib/RT/Record.pm
==============================================================================
--- rt/branches/3.5-TESTING/lib/RT/Record.pm (original)
+++ rt/branches/3.5-TESTING/lib/RT/Record.pm Wed Jul 6 09:47:11 2005
@@ -236,8 +236,12 @@
=head2 FirstAttribute NAME
-Returns the value of the first attribute with the matching name
-for this object, or C<undef> if no such attributes exist.
+Returns the first attribute with the matching name for this object (as an
+L<RT::Attribute> object), or C<undef> if no such attributes exist.
+
+Note that if there is more than one attribute with the matching name on the
+object, the choice of which one to return is basically arbitrary. This may be
+made well-defined in the future.
=cut
Modified: rt/branches/3.5-TESTING/lib/t/regression/13-attribute-tests.t
==============================================================================
--- rt/branches/3.5-TESTING/lib/t/regression/13-attribute-tests.t (original)
+++ rt/branches/3.5-TESTING/lib/t/regression/13-attribute-tests.t Wed Jul 6 09:47:11 2005
@@ -1,5 +1,6 @@
-
-use Test::More tests => 24;
+use strict;
+use warnings;
+use Test::More tests => 34;
use RT;
RT::LoadConfig();
RT::Init();
@@ -28,6 +29,12 @@
($id, $msg) = $user->AddAttribute(Name => 'TestAttr', Content => 'The attribute has content');
ok ($id, $msg);
is ($attr->Count,1, " One attr after adidng a first one");
+
+my $first_attr = $user->FirstAttribute('TestAttr');
+ok($first_attr, "got some sort of attribute");
+isa_ok($first_attr, 'RT::Attribute');
+is($first_attr->Content, 'The attribute has content', "got the right content back");
+
($id, $msg) = $attr->DeleteEntry(Name => $runid);
ok(!$id, "Deleted non-existant entry - $msg");
is ($attr->Count,1, "1 attr after deleting an empty attr");
@@ -37,11 +44,24 @@
($id, $msg) = $user->AddAttribute(Name => $runid, Content => "First");
+ok($id, $msg);
+
+my $runid_attr = $user->FirstAttribute($runid);
+ok($runid_attr, "got some sort of attribute");
+isa_ok($runid_attr, 'RT::Attribute');
+is($runid_attr->Content, 'First', "got the right content back");
is ($attr->Count,2, " Two attrs after adding an attribute named $runid");
($id, $msg) = $user->AddAttribute(Name => $runid, Content => "Second");
ok($id, $msg);
+$runid_attr = $user->FirstAttribute($runid);
+ok($runid_attr, "got some sort of attribute");
+isa_ok($runid_attr, 'RT::Attribute');
+TODO: { local $TODO = "which attribute is returned by FirstAttribute is undefined";
+ is($runid_attr->Content, 'First', "got the first content back still");
+}
+
is ($attr->Count,3, " Three attrs after adding a secondvalue to $runid");
($id, $msg) = $attr->DeleteEntry(Name => $runid, Content => "First");
ok($id, $msg);
More information about the Rt-commit
mailing list