6 use RT::Test nodata => 1, tests => 14;
8 use_ok('RT::Transactions');
11 my $q = RT::Queue->new(RT->SystemUser);
12 my ($id,$msg) = $q->Create( Name => 'TxnCFTest'.$$);
15 my $cf = RT::CustomField->new(RT->SystemUser);
16 ($id,$msg) = $cf->Create(Name => 'Txnfreeform-'.$$, Type => 'Freeform', MaxValues => '0', LookupType => RT::Transaction->CustomFieldLookupType );
20 ($id,$msg) = $cf->AddToObject($q);
25 my $ticket = RT::Ticket->new(RT->SystemUser);
28 ($id,$transid, $msg) = $ticket->Create(Queue => $q->id,
29 Subject => 'TxnCF test',
33 my $trans = RT::Transaction->new(RT->SystemUser);
34 $trans->Load($transid);
36 is($trans->ObjectId,$id);
37 is ($trans->ObjectType, 'RT::Ticket');
38 is ($trans->Type, 'Create');
39 my $txncfs = $trans->CustomFields;
40 is ($txncfs->Count, 1, "We have one custom field");
41 my $txn_cf = $txncfs->First;
42 is ($txn_cf->id, $cf->id, "It's the right custom field");
43 my $values = $trans->CustomFieldValues($txn_cf->id);
44 is ($values->Count, 0, "It has no values");
47 my %cf_updates = ( 'CustomField-'.$cf->id => 'Testing');
48 $trans->UpdateCustomFields( ARGSRef => \%cf_updates);
50 $values = $trans->CustomFieldValues($txn_cf->id);
51 is ($values->Count, 1, "It has one value");
55 $trans->UpdateCustomFields( 'CustomField-'.$cf->id => 'Test two');
56 $values = $trans->CustomFieldValues($txn_cf->id);
57 is ($values->Count, 2, "it has two values");
59 # TODO ok(0, "Should updating custom field values remove old values?");