6 use RT::Test nodata => 1, tests => 13;
10 return $class->new(RT->SystemUser);
13 use constant VALUES_CLASS => 'RT::CustomFieldValues::Groups';
14 RT->Config->Set(CustomFieldValuesSources => VALUES_CLASS);
16 my $q = new( RT::Queue );
17 isa_ok( $q, 'RT::Queue' );
18 my ($qid) = $q->Create( Name => "CF-External-". $$ );
19 ok( $qid, "created queue" );
20 my %arg = ( Name => $q->Name,
24 ValuesClass => VALUES_CLASS );
26 my $cf = new( RT::CustomField );
27 isa_ok( $cf, 'RT::CustomField' );
30 my ($cfid, $msg) = $cf->Create( %arg );
31 ok( $cfid, "created cf" ) or diag "error: $msg";
32 is( $cf->ValuesClass, VALUES_CLASS, "right values class" );
33 ok( $cf->IsExternalValues, "custom field has external values" );
37 # create at least on group for the tests
38 my $group = RT::Group->new( RT->SystemUser );
39 my ($ret, $msg) = $group->CreateUserDefinedGroup( Name => $q->Name );
40 ok $ret, 'created group' or diag "error: $msg";
44 my $values = $cf->Values;
45 isa_ok( $values, VALUES_CLASS );
46 ok( $values->Count, "we have values" );
47 my ($failure, $count) = (0, 0);
48 while( my $value = $values->Next ) {
50 $failure = 1 unless $value->Name;
52 ok( !$failure, "all values have name" );
53 is( $values->Count, $count, "count is correct" );
57 my ($ret, $msg) = $cf->SetValuesClass('RT::CustomFieldValues');
58 ok $ret, 'Reverting this CF as internal source values based' or diag "error: $msg";
59 ($ret, $msg) = $cf->SetValuesClass('RT::CustomFieldValues::Groups');
60 ok $ret, 'Reverting this CF as external source values based' or diag "error: $msg";