8 # This test script validates that when merging two tickets, the comments from both tickets
9 # are integrated into the new ticket
11 use Test::More tests => 13;
19 my $queue = RT::Queue->new($RT::SystemUser);
20 my ($id,$msg) = $queue->Create(Name => 'MergeTest-'.rand(25));
23 my $t1 = RT::Ticket->new($RT::SystemUser);
24 my ($tid,$transid, $t1msg) =$t1->Create ( Queue => $queue->Name, Subject => 'Merge test. orig');
26 ($id, $msg) = $t1->Comment(Content => 'This is a Comment on the original');
29 my $txns = $t1->Transactions;
31 while (my $txn = $txns->Next) {
32 $Comments++ if ($txn->Type eq 'Comment');
34 is($Comments,1, "our first ticket has only one Comment");
36 my $t2 = RT::Ticket->new($RT::SystemUser);
37 my ($t2id,$t2transid, $t2msg) =$t2->Create ( Queue => $queue->Name, Subject => 'Merge test. duplicate');
42 ($id, $msg) = $t2->Comment(Content => 'This is a commet on the duplicate');
46 $txns = $t2->Transactions;
48 while (my $txn = $txns->Next) {
49 $Comments++ if ($txn->Type eq 'Comment');
51 is($Comments,1, "our second ticket has only one Comment");
53 ($id, $msg) = $t1->Comment(Content => 'This is a second Comment on the original');
56 $txns = $t1->Transactions;
58 while (my $txn = $txns->Next) {
59 $Comments++ if ($txn->Type eq 'Comment');
61 is($Comments,2, "our first ticket now has two Comments");
63 ($id,$msg) = $t2->MergeInto($t1->id);
66 $txns = $t1->Transactions;
68 while (my $txn = $txns->Next) {
69 $Comments++ if ($txn->Type eq 'Comment');
71 is($Comments,3, "our first ticket now has three Comments - we merged safely");