5 use RT::Test tests => 14;
8 my $q1 = RT::Test->load_or_create_queue( Name => 'One' );
9 ok $q1 && $q1->id, 'loaded or created queue';
11 my $q2 = RT::Test->load_or_create_queue( Name => 'Two' );
12 ok $q2 && $q2->id, 'loaded or created queue';
14 my @tickets = add_tix_from_data(
15 { Queue => $q1->id, Resolved => 3*60 },
16 { Queue => $q1->id, Resolved => 3*60*60 },
17 { Queue => $q1->id, Resolved => 3*24*60*60 },
18 { Queue => $q1->id, Resolved => 3*30*24*60*60 },
19 { Queue => $q1->id, Resolved => 9*30*24*60*60 },
20 { Queue => $q2->id, Resolved => 7*60 },
21 { Queue => $q2->id, Resolved => 7*60*60 },
22 { Queue => $q2->id, Resolved => 7*24*60*60 },
23 { Queue => $q2->id, Resolved => 7*30*24*60*60 },
24 { Queue => $q2->id, Resolved => 24*30*24*60*60 },
27 use_ok 'RT::Report::Tickets';
30 my $report = RT::Report::Tickets->new( RT->SystemUser );
31 my %columns = $report->SetupGroupings(
34 Function => ['ALL(Created-Resolved)'],
38 my @colors = RT->Config->Get("ChartColors");
43 { 'rowspan' => 2, 'value' => 'Queue', 'type' => 'head' },
44 { 'colspan' => 4, 'value' => 'Summary of Created-Resolved', 'type' => 'head' }
49 { 'value' => 'Minimum', 'type' => 'head', 'color' => $colors[0] },
50 { 'value' => 'Average', 'type' => 'head', 'color' => $colors[1] },
51 { 'value' => 'Maximum', 'type' => 'head', 'color' => $colors[2] },
52 { 'value' => 'Total', 'type' => 'head', 'color' => $colors[3] }
59 { 'colspan' => 1, 'value' => 'Total', 'type' => 'label' },
60 { 'value' => '10m', 'type' => 'value' },
61 { 'value' => '8M 2W 3d', 'type' => 'value' },
62 { 'value' => '2Y 8M 2W', 'type' => 'value' },
63 { 'value' => '3Y 6M 3W', 'type' => 'value' }
71 { 'value' => 'One', 'type' => 'label' },
72 { 'query' => '(Queue = 3)', 'value' => '3m', 'type' => 'value' },
73 { 'query' => '(Queue = 3)', 'value' => '2M 1W 5d', 'type' => 'value' },
74 { 'query' => '(Queue = 3)', 'value' => '8M 3W 6d', 'type' => 'value' },
75 { 'query' => '(Queue = 3)', 'value' => '11M 4W 8h', 'type' => 'value' }
81 { 'value' => 'Two', 'type' => 'label' },
82 { 'query' => '(Queue = 4)', 'value' => '7m', 'type' => 'value' },
83 { 'query' => '(Queue = 4)', 'value' => '6M 4d 20h', 'type' => 'value' },
84 { 'query' => '(Queue = 4)', 'value' => '1Y 11M 3W', 'type' => 'value' },
85 { 'query' => '(Queue = 4)', 'value' => '2Y 6M 3W', 'type' => 'value' }
92 my %table = $report->FormatTable( %columns );
93 is_deeply( \%table, $expected, "basic table" );
97 sub add_tix_from_data {
101 my $created = RT::Date->new( $RT::SystemUser );
104 my $resolved = RT::Date->new( $RT::SystemUser );
107 $resolved->Set( Value => $created->Unix );
108 $resolved->AddSeconds( $data[0]{'Resolved'} );
109 my $t = RT::Ticket->new($RT::SystemUser);
110 my ( $id, undef $msg ) = $t->Create(
112 Created => $created->ISO,
113 Resolved => $resolved->ISO,
115 ok( $id, "ticket created" ) or diag("error: $msg");