7 use RT::Test nodata => 1, tests => 11;
11 return $class->new(RT->SystemUser);
14 use constant VALUES_CLASS => 'RT::CustomFieldValues::Groups';
15 RT->Config->Set(CustomFieldValuesSources => VALUES_CLASS);
17 my $q = new( RT::Queue );
18 isa_ok( $q, 'RT::Queue' );
19 my ($qid) = $q->Create( Name => "CF-External-". $$ );
20 ok( $qid, "created queue" );
21 my %arg = ( Name => $q->Name,
25 ValuesClass => VALUES_CLASS );
27 my $cf = new( RT::CustomField );
28 isa_ok( $cf, 'RT::CustomField' );
31 my ($cfid, $msg) = $cf->Create( %arg );
32 ok( $cfid, "created cf" ) or diag "error: $msg";
33 is( $cf->ValuesClass, VALUES_CLASS, "right values class" );
34 ok( $cf->IsExternalValues, "custom field has external values" );
38 # create at least on group for the tests
39 my $group = RT::Group->new( RT->SystemUser );
40 my ($ret, $msg) = $group->CreateUserDefinedGroup( Name => $q->Name );
41 ok $ret, 'created group' or diag "error: $msg";
45 my $values = $cf->Values;
46 isa_ok( $values, VALUES_CLASS );
47 ok( $values->Count, "we have values" );
48 my ($failure, $count) = (0, 0);
49 while( my $value = $values->Next ) {
51 $failure = 1 unless $value->Name;
53 ok( !$failure, "all values have name" );
54 is( $values->Count, $count, "count is correct" );