diff options
author | Max Kanat-Alexander <mkanat@bugzilla.org> | 2010-07-16 04:55:10 +0200 |
---|---|---|
committer | Max Kanat-Alexander <mkanat@bugzilla.org> | 2010-07-16 04:55:10 +0200 |
commit | dbaf1c3aaf975ed78d8e8538b2df18ab9f47654b (patch) | |
tree | db913e59441783297ad780e89cd372897a6ec184 /xt | |
parent | 6a2a01fbc44c5a777b3a612540a9ced23401c2bc (diff) | |
download | bugzilla-dbaf1c3aaf975ed78d8e8538b2df18ab9f47654b.tar.gz bugzilla-dbaf1c3aaf975ed78d8e8538b2df18ab9f47654b.tar.xz |
Bug 398308: Make Search.pm take a hashref for its "params" argument
instead of taking a CGI object.
r=mkanat, a=mkanat (module owner)
Diffstat (limited to 'xt')
-rw-r--r-- | xt/lib/Bugzilla/Test/Search/AndTest.pm | 11 | ||||
-rw-r--r-- | xt/lib/Bugzilla/Test/Search/FakeCGI.pm | 61 | ||||
-rw-r--r-- | xt/lib/Bugzilla/Test/Search/FieldTest.pm | 18 | ||||
-rw-r--r-- | xt/lib/Bugzilla/Test/Search/OrTest.pm | 11 |
4 files changed, 17 insertions, 84 deletions
diff --git a/xt/lib/Bugzilla/Test/Search/AndTest.pm b/xt/lib/Bugzilla/Test/Search/AndTest.pm index d7b21af48..b4554584b 100644 --- a/xt/lib/Bugzilla/Test/Search/AndTest.pm +++ b/xt/lib/Bugzilla/Test/Search/AndTest.pm @@ -25,7 +25,6 @@ package Bugzilla::Test::Search::AndTest; use base qw(Bugzilla::Test::Search::OrTest); use Bugzilla::Test::Search::Constants; -use Bugzilla::Test::Search::FakeCGI; use List::MoreUtils qw(all); use constant type => 'AND'; @@ -55,15 +54,15 @@ sub _join_broken_constant { {} } sub search_params { my ($self) = @_; my @all_params = map { $_->search_params } $self->field_tests; - my $params = new Bugzilla::Test::Search::FakeCGI; + my %params; my $chart = 0; foreach my $item (@all_params) { - $params->param("field0-$chart-0", $item->param('field0-0-0')); - $params->param("type0-$chart-0", $item->param('type0-0-0')); - $params->param("value0-$chart-0", $item->param('value0-0-0')); + $params{"field0-$chart-0"} = $item->{'field0-0-0'}; + $params{"type0-$chart-0"} = $item->{'type0-0-0'}; + $params{"value0-$chart-0"} = $item->{'value0-0-0'}; $chart++; } - return $params; + return \%params; } 1;
\ No newline at end of file diff --git a/xt/lib/Bugzilla/Test/Search/FakeCGI.pm b/xt/lib/Bugzilla/Test/Search/FakeCGI.pm deleted file mode 100644 index e20a57daf..000000000 --- a/xt/lib/Bugzilla/Test/Search/FakeCGI.pm +++ /dev/null @@ -1,61 +0,0 @@ -# -*- Mode: perl; indent-tabs-mode: nil -*- -# -# The contents of this file are subject to the Mozilla Public -# License Version 1.1 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is the Bugzilla Bug Tracking System. -# -# The Initial Developer of the Original Code is Everything Solved, Inc. -# Portions created by the Initial Developer are Copyright (C) 2010 the -# Initial Developer. All Rights Reserved. -# -# Contributor(s): -# Max Kanat-Alexander <mkanat@bugzilla.org> - -# Calling CGI::param over and over turned out to be one of the slowest -# parts of search.t. So we create a simpler thing here that just supports -# "param" in a fast way. -package Bugzilla::Test::Search::FakeCGI; - -sub new { - my ($class) = @_; - return bless {}, $class; -} - -sub param { - my ($self, $name, @values) = @_; - if (!defined $name) { - return keys %$self; - } - - if (@values) { - if (ref $values[0] eq 'ARRAY') { - $self->{$name} = $values[0]; - } - else { - $self->{$name} = \@values; - } - } - - return () if !exists $self->{$name}; - - my $item = $self->{$name}; - return wantarray ? @{ $item || [] } : $item->[0]; -} - -sub delete { - my ($self, $name) = @_; - delete $self->{$name}; -} - -# We don't need to do this, because we don't use old params in search.t. -sub convert_old_params {} - -1;
\ No newline at end of file diff --git a/xt/lib/Bugzilla/Test/Search/FieldTest.pm b/xt/lib/Bugzilla/Test/Search/FieldTest.pm index 4d24c5bd3..558742f71 100644 --- a/xt/lib/Bugzilla/Test/Search/FieldTest.pm +++ b/xt/lib/Bugzilla/Test/Search/FieldTest.pm @@ -26,7 +26,6 @@ package Bugzilla::Test::Search::FieldTest; use strict; use warnings; -use Bugzilla::Test::Search::FakeCGI; use Bugzilla::Search; use Bugzilla::Test::Search::Constants; @@ -278,19 +277,16 @@ sub join_broken { # The CGI object that will get passed to Bugzilla::Search as its arguments. sub search_params { - my $self = shift; + my ($self) = @_; return $self->{search_params} if $self->{search_params}; - my $field = $self->field; - my $operator = $self->operator; - my $value = $self->translated_value; - - my $cgi = new Bugzilla::Test::Search::FakeCGI; - $cgi->param("field0-0-0", $field); - $cgi->param('type0-0-0', $operator); - $cgi->param('value0-0-0', $value); + my %params = ( + "field0-0-0" => $self->field, + "type0-0-0" => $self->operator, + "value0-0-0" => $self->translated_value, + ); - $self->{search_params} = $cgi; + $self->{search_params} = \%params; return $self->{search_params}; } diff --git a/xt/lib/Bugzilla/Test/Search/OrTest.pm b/xt/lib/Bugzilla/Test/Search/OrTest.pm index 101e19fd5..35653d0f0 100644 --- a/xt/lib/Bugzilla/Test/Search/OrTest.pm +++ b/xt/lib/Bugzilla/Test/Search/OrTest.pm @@ -25,7 +25,6 @@ package Bugzilla::Test::Search::OrTest; use base qw(Bugzilla::Test::Search::FieldTest); use Bugzilla::Test::Search::Constants; -use Bugzilla::Test::Search::FakeCGI; use List::MoreUtils qw(any uniq); use constant type => 'OR'; @@ -172,15 +171,15 @@ sub search_columns { sub search_params { my ($self) = @_; my @all_params = map { $_->search_params } $self->field_tests; - my $params = new Bugzilla::Test::Search::FakeCGI; + my %params; my $chart = 0; foreach my $item (@all_params) { - $params->param("field0-0-$chart", $item->param('field0-0-0')); - $params->param("type0-0-$chart", $item->param('type0-0-0')); - $params->param("value0-0-$chart", $item->param('value0-0-0')); + $params{"field0-0-$chart"} = $item->{'field0-0-0'}; + $params{"type0-0-$chart"} = $item->{'type0-0-0'}; + $params{"value0-0-$chart"} = $item->{'value0-0-0'}; $chart++; } - return $params; + return \%params; } 1;
\ No newline at end of file |