7 use RT::Test tests => 14;
9 use_ok('RT::Transactions');
12 my $q = RT::Queue->new($RT::SystemUser);
13 my ($id,$msg) = $q->Create( Name => 'TxnCFTest'.$$);
16 my $cf = RT::CustomField->new($RT::SystemUser);
17 ($id,$msg) = $cf->Create(Name => 'Txnfreeform-'.$$, Type => 'Freeform', MaxValues => '0', LookupType => RT::Transaction->CustomFieldLookupType );
21 ($id,$msg) = $cf->AddToObject($q);
26 my $ticket = RT::Ticket->new($RT::SystemUser);
29 ($id,$transid, $msg) = $ticket->Create(Queue => $q->id,
30 Subject => 'TxnCF test',
34 my $trans = RT::Transaction->new($RT::SystemUser);
35 $trans->Load($transid);
37 is($trans->ObjectId,$id);
38 is ($trans->ObjectType, 'RT::Ticket');
39 is ($trans->Type, 'Create');
40 my $txncfs = $trans->CustomFields;
41 is ($txncfs->Count, 1, "We have one custom field");
42 my $txn_cf = $txncfs->First;
43 is ($txn_cf->id, $cf->id, "It's the right custom field");
44 my $values = $trans->CustomFieldValues($txn_cf->id);
45 is ($values->Count, 0, "It has no values");
48 my %cf_updates = ( 'CustomField-'.$cf->id => 'Testing');
49 $trans->UpdateCustomFields( ARGSRef => \%cf_updates);
51 $values = $trans->CustomFieldValues($txn_cf->id);
52 is ($values->Count, 1, "It has one value");
56 $trans->UpdateCustomFields( 'CustomField-'.$cf->id => 'Test two');
57 $values = $trans->CustomFieldValues($txn_cf->id);
58 is ($values->Count, 2, "it has two values");
60 # TODO ok(0, "Should updating custom field values remove old values?");