6 use Test::More qw/no_plan/;
9 use_ok('RT::Transactions');
13 my $q = RT::Queue->new($RT::SystemUser);
14 my ($id,$msg) = $q->Create( Name => 'TxnCFTest'.$$);
17 my $cf = RT::CustomField->new($RT::SystemUser);
18 ($id,$msg) = $cf->Create(Name => 'Txnfreeform-'.$$, Type => 'Freeform', MaxValues => '0', LookupType => RT::Transaction->CustomFieldLookupType );
22 ($id,$msg) = $cf->AddToObject($q);
27 my $ticket = RT::Ticket->new($RT::SystemUser);
30 ($id,$transid, $msg) = $ticket->Create(Queue => $q->id,
31 Subject => 'TxnCF test',
35 my $trans = RT::Transaction->new($RT::SystemUser);
36 $trans->Load($transid);
38 is($trans->ObjectId,$id);
39 is ($trans->ObjectType, 'RT::Ticket');
40 is ($trans->Type, 'Create');
41 my $txncfs = $trans->CustomFields;
42 is ($txncfs->Count, 1, "We have one custom field");
43 my $txn_cf = $txncfs->First;
44 is ($txn_cf->id, $cf->id, "It's the right custom field");
45 my $values = $trans->CustomFieldValues($txn_cf->id);
46 is ($values->Count, 0, "It has no values");
49 my %cf_updates = ( 'CustomField-'.$cf->id => 'Testing');
50 $trans->UpdateCustomFields( ARGSRef => \%cf_updates);
52 $values = $trans->CustomFieldValues($txn_cf->id);
53 is ($values->Count, 1, "It has one value");
57 $trans->UpdateCustomFields( 'CustomField-'.$cf->id => 'Test two');
58 $values = $trans->CustomFieldValues($txn_cf->id);
59 is ($values->Count, 2, "it has two values");
61 # TODO ok(0, "Should updating custom field values remove old values?");