4 use RT::Test tests => undef;
7 my $q = RT::Test->load_or_create_queue( Name => 'General' );
8 ok $q && $q->id, 'loaded or created queue';
11 my @tickets = add_tix_from_data(
12 { Subject => 'n', Status => 'new' },
13 { Subject => 'o', Status => 'open' },
14 { Subject => 'o', Status => 'open' },
15 { Subject => 'r', Status => 'resolved' },
16 { Subject => 'r', Status => 'resolved' },
17 { Subject => 'r', Status => 'resolved' },
20 use_ok 'RT::Report::Tickets';
23 my $report = RT::Report::Tickets->new( RT->SystemUser );
24 my %columns = $report->SetupGroupings(
25 Query => 'Queue = '. $q->id,
26 GroupBy => ['Status'],
27 Function => ['COUNT'],
31 my @colors = RT->Config->Get("ChartColors");
35 { 'value' => 'Status', 'type' => 'head' },
36 { 'rowspan' => 1, 'value' => 'Ticket count', 'type' => 'head', 'color' => $colors[0] },
41 { 'colspan' => 1, 'value' => 'Total', 'type' => 'label' },
42 { 'value' => 6, 'type' => 'value' },
49 { 'value' => 'new', 'type' => 'label' },
50 { 'query' => '(Status = \'new\')', 'value' => '1', 'type' => 'value' },
56 { 'value' => 'open', 'type' => 'label' },
57 { 'query' => '(Status = \'open\')', 'value' => '2', 'type' => 'value' }
63 { 'value' => 'resolved', 'type' => 'label' },
64 { 'query' => '(Status = \'resolved\')', 'value' => '3', 'type' => 'value' }
71 my %table = $report->FormatTable( %columns );
72 is_deeply( \%table, $expected, "basic table" );
78 sub add_tix_from_data {
82 my %info = %{ shift(@data) };
83 my $t = RT::Ticket->new($RT::SystemUser);
84 my ( $id, undef, $msg ) = $t->Create( Queue => $q->id, %info );
85 ok( $id, "ticket created" ) or diag("error: $msg");
86 is $t->Status, $info{'Status'}, 'correct status';