X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=rt%2Ft%2Fapi%2Fcf_external.t;fp=rt%2Ft%2Fapi%2Fcf_external.t;h=076871240b4d44c769d70e205d68c93181cc8916;hb=b4b0c7e72d7eaee2fbfc7022022c9698323203dd;hp=0000000000000000000000000000000000000000;hpb=2dfda73eeb3eae2d4f894099754794ef07d060dd;p=freeside.git diff --git a/rt/t/api/cf_external.t b/rt/t/api/cf_external.t new file mode 100644 index 000000000..076871240 --- /dev/null +++ b/rt/t/api/cf_external.t @@ -0,0 +1,56 @@ +#!/usr/bin/perl + +use warnings; +use strict; + +use RT; +use RT::Test nodata => 1, tests => 11; + +sub new (*) { + my $class = shift; + return $class->new($RT::SystemUser); +} + +use constant VALUES_CLASS => 'RT::CustomFieldValues::Groups'; + +my $q = new( RT::Queue ); +isa_ok( $q, 'RT::Queue' ); +my ($qid) = $q->Create( Name => "CF-External-". $$ ); +ok( $qid, "created queue" ); +my %arg = ( Name => $q->Name, + Type => 'Select', + Queue => $q->id, + MaxValues => 1, + ValuesClass => VALUES_CLASS ); + +my $cf = new( RT::CustomField ); +isa_ok( $cf, 'RT::CustomField' ); + +{ + my ($cfid) = $cf->Create( %arg ); + ok( $cfid, "created cf" ); + is( $cf->ValuesClass, VALUES_CLASS, "right values class" ); + ok( $cf->IsExternalValues, "custom field has external values" ); +} + +{ + # create at least on group for the tests + my $group = RT::Group->new( $RT::SystemUser ); + my ($ret, $msg) = $group->CreateUserDefinedGroup( Name => $q->Name ); + ok $ret, 'created group' or diag "error: $msg"; +} + +{ + my $values = $cf->Values; + isa_ok( $values, VALUES_CLASS ); + ok( $values->Count, "we have values" ); + my ($failure, $count) = (0, 0); + while( my $value = $values->Next ) { + $count++; + $failure = 1 unless $value->Name; + } + ok( !$failure, "all values have name" ); + is( $values->Count, $count, "count is correct" ); +} + +exit(0);