diff options
| author | ivan <ivan> | 2008-03-02 04:11:51 +0000 | 
|---|---|---|
| committer | ivan <ivan> | 2008-03-02 04:11:51 +0000 | 
| commit | c648976f0b7975f2328ebd7ba8c711fad0ca4195 (patch) | |
| tree | f3d176ec300a46c253ba25a988b897bce02fe174 /rt/lib/RT/Tickets_Overlay_SQL.pm | |
| parent | 5e05724a635a22776f1b973f5d7e77989da4e048 (diff) | |
| parent | 8103c1fc1b2c27a6855feadf26f91b980a54bc52 (diff) | |
This commit was generated by cvs2svn to compensate for changes in r6255,
which included commits to RCS files with non-trunk default branches.
Diffstat (limited to 'rt/lib/RT/Tickets_Overlay_SQL.pm')
| -rw-r--r-- | rt/lib/RT/Tickets_Overlay_SQL.pm | 103 | 
1 files changed, 54 insertions, 49 deletions
| diff --git a/rt/lib/RT/Tickets_Overlay_SQL.pm b/rt/lib/RT/Tickets_Overlay_SQL.pm index 525f252af..4531a1690 100644 --- a/rt/lib/RT/Tickets_Overlay_SQL.pm +++ b/rt/lib/RT/Tickets_Overlay_SQL.pm @@ -2,7 +2,7 @@  #   # COPYRIGHT:  #   -# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC  +# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC   #                                          <jesse@bestpractical.com>  #   # (Except where explicitly superseded by other copyright notices) @@ -22,7 +22,9 @@  #   # You should have received a copy of the GNU General Public License  # along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301 or visit their web page on the internet at +# http://www.gnu.org/copyleft/gpl.html.  #   #   # CONTRIBUTION SUBMISSION POLICY: @@ -51,12 +53,12 @@ use warnings;  # Import configuration data from the lexcial scope of __PACKAGE__ (or  # at least where those two Subroutines are defined.) -my %FIELDS = %{FIELDS()}; +my %FIELD_METADATA = %{FIELDS()};  my %dispatch = %{dispatch()};  my %can_bundle = %{can_bundle()};  # Lower Case version of FIELDS, for case insensitivity -my %lcfields = map { ( lc($_) => $_ ) } (keys %FIELDS); +my %lcfields = map { ( lc($_) => $_ ) } (keys %FIELD_METADATA);  sub _InitSQL {    my $self = shift; @@ -299,7 +301,7 @@ sub _parser {        my $class;        if (exists $lcfields{lc $key}) {          $key = $lcfields{lc $key}; -        $class = $FIELDS{$key}->[0]; +        $class = $FIELD_METADATA{$key}->[0];        }     # no longer have a default, since CF's are now a real class, not fallthrough     # fixme: "default class" is not Generic. @@ -403,63 +405,66 @@ failure.  =begin testing  use RT::Tickets; - - +use strict;  my $tix = RT::Tickets->new($RT::SystemUser); +{ +    my $query = "Status = 'open'"; +    my ($status, $msg)  = $tix->FromSQL($query); +    ok ($status, "correct query") or diag("error: $msg"); +} -my $query = "Status = 'open'"; -my ($id, $msg)  = $tix->FromSQL($query); - -ok ($id, $msg); - - -my (@ids, @expectedids); - -my $t = RT::Ticket->new($RT::SystemUser); +my (@created,%created);  my $string = 'subject/content SQL test'; -ok( $t->Create(Queue => 'General', Subject => $string), "Ticket Created"); - -push @ids, $t->Id; - -my $Message = MIME::Entity->build( -			     Subject     => 'this is my subject', -			     From        => 'jesse@example.com', -			     Data        => [ $string ], -        ); - -ok( $t->Create(Queue => 'General', Subject => 'another ticket', MIMEObj => $Message, MemberOf => $ids[0]), "Ticket Created"); - -push @ids, $t->Id; - -$query = ("Subject LIKE '$string' OR Content LIKE '$string'"); - -my ($id, $msg) = $tix->FromSQL($query); - - -ok ($id, $msg); - -is ($tix->Count, scalar @ids, "number of returned tickets same as entered"); -while (my $tick = $tix->Next) { -    push @expectedids, $tick->Id; +{ +    my $t = RT::Ticket->new($RT::SystemUser); +    ok( $t->Create(Queue => 'General', Subject => $string), "Ticket Created"); +    $created{ $t->Id }++; push @created, $t->Id;  } -ok (eq_array(\@ids, \@expectedids), "returned expected tickets"); -$query = ("id = $ids[0] OR MemberOf = $ids[0]"); +{ +    my $Message = MIME::Entity->build( +                     Subject     => 'this is my subject', +                     From        => 'jesse@example.com', +                     Data        => [ $string ], +            ); + +    my $t = RT::Ticket->new($RT::SystemUser); +    ok( $t->Create( Queue => 'General', +                    Subject => 'another ticket', +                    MIMEObj => $Message, +                    MemberOf => $created[0] +                  ), +        "Ticket Created" +    ); +    $created{ $t->Id }++; push @created, $t->Id; +} -my ($id, $msg) = $tix->FromSQL($query); +{ +    my $query = ("Subject LIKE '$string' OR Content LIKE '$string'"); +    my ($status, $msg) = $tix->FromSQL($query); +    ok ($status, "correct query") or diag("error: $msg"); -ok ($id, $msg); +    my $count = 0; +    while (my $tick = $tix->Next) { +        $count++ if $created{ $tick->id }; +    } +    is ($count, scalar @created, "number of returned tickets same as entered"); +} -is ($tix->Count, scalar @ids, "number of returned tickets same as entered"); +{ +    my $query = "id = $created[0] OR MemberOf = $created[0]"; +    my ($status, $msg) = $tix->FromSQL($query); +    ok ($status, "correct query") or diag("error: $msg"); -@expectedids = (); -while (my $tick = $tix->Next) { -    push @expectedids, $tick->Id; +    my $count = 0; +    while (my $tick = $tix->Next) { +        $count++ if $created{ $tick->id }; +    } +    is ($count, scalar @created, "number of returned tickets same as entered");  } -ok (eq_array(\@ids, \@expectedids), "returned expected tickets");  =end testing | 
