File Coverage

test/Romani/Query/SQL/TTT.pm
Criterion Covered Total %
statement 39 58 67.2
branch n/a
condition n/a
subroutine 13 16 81.2
pod n/a
total 52 74 70.2


line stmt bran cond sub pod time code
1             #!/usr/bin/perl -w
2              
3             package Local::Romani::Query::SQL::TTT;
4 1     1   908 use base qw(Test::Class);
  1         3  
  1         93  
5              
6 1     1   608 use DBIx::Romani::Query::SQL::TTT::Operator;
  1         3  
  1         30  
7 1     1   5 use DBIx::Romani::Query::SQL::TTT::Function;
  1         2  
  1         21  
8 1     1   5 use DBIx::Romani::Query::SQL::TTT::Keyword;
  1         2  
  1         27  
9 1     1   5 use DBIx::Romani::Query::SQL::TTT::Join;
  1         2  
  1         20  
10 1     1   4 use DBIx::Romani::Query::SQL::Column;
  1         2  
  1         24  
11 1     1   5 use DBIx::Romani::Query::SQL::Literal;
  1         7  
  1         24  
12 1     1   5 use DBIx::Romani::Driver::sqlite;
  1         2  
  1         20  
13 1     1   5 use Test::More;
  1         1  
  1         7  
14 1     1   297 use strict;
  1         2  
  1         33  
15              
16 1     1   5 use Data::Dumper;
  1         2  
  1         309  
17              
18             # utility function makes SQL out of whatever
19 0     0     sub generate_sql { return DBIx::Romani::Driver::sqlite->new()->generate_sql( @_ ) };
20              
21             sub tttOperator1 : Test(1)
22             {
23 0     0   0 my $op_eq1 = DBIx::Romani::Query::SQL::TTT::Operator->new( '=' );
24 0         0 $op_eq1->add( DBIx::Romani::Query::SQL::Column->new(undef, 'column1') );
25 0         0 $op_eq1->add( DBIx::Romani::Query::SQL::Literal->new('ABC') );
26              
27 0         0 my $op_eq2 = DBIx::Romani::Query::SQL::TTT::Operator->new( '=' );
28 0         0 $op_eq2->add( DBIx::Romani::Query::SQL::Column->new(undef, 'column2') );
29 0         0 $op_eq2->add( DBIx::Romani::Query::SQL::Literal->new('123') );
30              
31 0         0 my $op_and = DBIx::Romani::Query::SQL::TTT::Operator->new( 'and' );
32 0         0 $op_and->add( $op_eq1 );
33 0         0 $op_and->add( $op_eq2 );
34              
35 0         0 my $s = generate_sql( $op_and );
36 0         0 is( $s, "((column1 = 'ABC') and (column2 = '123'))" );
37 1     1   5 }
  1         2  
  1         6  
38              
39             sub tttFunction1 : Test(1)
40             {
41 0     0     my $func = DBIx::Romani::Query::SQL::TTT::Function->new( "COUNT" );
42 0           my $ttt_join = DBIx::Romani::Query::SQL::TTT::Join->new();
43 0           $ttt_join->add( DBIx::Romani::Query::SQL::TTT::Keyword->new('DISTINCT') );
44 0           $ttt_join->add( DBIx::Romani::Query::SQL::Column->new( undef, "column1" ) );
45 0           $func->add( $ttt_join );
46              
47 0           my $s = generate_sql( $func );
48 0           is( $s, 'COUNT(DISTINCT column1)' );
49 1     1   343 }
  1         2  
  1         3  
50              
51             1;
52