5 use RT::Test nodata => 1, tests => 29;
11 use_ok('RT::CustomField');
12 ok(my $cf = RT::CustomField->new(RT->SystemUser));
13 ok(my ($id, $msg)= $cf->Create( Name => 'TestingCF',
16 Description => 'A Testing custom field',
17 Type=> 'SelectSingle'), 'Created a global CustomField');
18 isnt($id , 0, 'Global custom field correctly created');
19 ok ($cf->SingleValue);
20 is($cf->Type, 'Select');
21 is($cf->MaxValues, 1);
23 (my $val, $msg) = $cf->SetMaxValues('0');
25 is($cf->Type, 'Select');
26 is($cf->MaxValues, 0);
27 ok(!$cf->SingleValue );
28 ok(my ($bogus_val, $bogus_msg) = $cf->SetType('BogusType') , "Trying to set a custom field's type to a bogus type");
29 is($bogus_val , 0, "Unable to set a custom field's type to a bogus type");
31 ok(my $bad_cf = RT::CustomField->new(RT->SystemUser));
32 ok(my ($bad_id, $bad_msg)= $cf->Create( Name => 'TestingCF-bad',
35 Description => 'A Testing custom field with a bogus Type',
36 Type=> 'SelectSingleton'), 'Created a global CustomField with a bogus type');
37 is($bad_id , 0, 'Global custom field correctly decided to not create a cf with a bogus type ');
44 ok(my $cf = RT::CustomField->new(RT->SystemUser));
47 ok(my ($val,$msg) = $cf->AddValue(Name => 'foo' , Description => 'TestCFValue', SortOrder => '6'));
49 ok (my ($delval, $delmsg) = $cf->DeleteValue($val));
50 ok ($delval,"Deleting a cf value: $delmsg");
57 ok(my $cf = RT::CustomField->new(RT->SystemUser));
60 ok($cf->ValidateType('SelectSingle'));
64 ok($cf->ValidateType('SelectMultiple'));
68 ok(!$cf->ValidateType('SelectFooMultiple'));