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 $cf = RT::CustomField->new(RT->SystemUser);
12 my ($id,$msg) = $cf->Create(Name => 'Test', Type => 'Freeform', MaxValues => '1', Queue => $q->id);
17 my @tickets = RT::Test->create_tickets(
19 { Subject => 't1', Status => 'new', CustomFields => { Test => 'a' } },
20 { Subject => 't2', Status => 'open', CustomFields => { Test => 'b' } },
23 use_ok 'RT::Report::Tickets';
26 my $report = RT::Report::Tickets->new( RT->SystemUser );
27 my %columns = $report->SetupGroupings(
28 Query => 'Queue = '. $q->id,
29 GroupBy => ["CF.{$cfid}"], # TODO: CF.{Name} is not supported at the moment
30 Function => ['COUNT'],
34 my @colors = RT->Config->Get("ChartColors");
38 { 'value' => 'Custom field Test', 'type' => 'head' },
39 { 'rowspan' => 1, 'value' => 'Ticket count', 'type' => 'head', 'color' => $colors[0] },
44 { 'colspan' => 1, 'value' => 'Total', 'type' => 'label' },
45 { 'value' => 2, 'type' => 'value' },
52 { 'value' => 'a', 'type' => 'label' },
53 { 'query' => "(CF.{$cfid} = 'a')", 'value' => '1', 'type' => 'value' },
59 { 'value' => 'b', 'type' => 'label' },
60 { 'query' => "(CF.{$cfid} = 'b')", 'value' => '1', 'type' => 'value' },
67 my %table = $report->FormatTable( %columns );
68 is_deeply( \%table, $expected, "basic table" );