diff options
author | Max Kanat-Alexander <mkanat@bugzilla.org> | 2010-07-07 23:34:25 +0200 |
---|---|---|
committer | Max Kanat-Alexander <mkanat@bugzilla.org> | 2010-07-07 23:34:25 +0200 |
commit | 87ea46f7fa2b269f065181f7765352184bb59717 (patch) | |
tree | 20e37379d319535c954480e86765a580342118bd /xt/lib/Bugzilla/Test/Search/AndTest.pm | |
parent | 814b24fdc9407a741967322041ff817665f8e00b (diff) | |
download | bugzilla-87ea46f7fa2b269f065181f7765352184bb59717.tar.gz bugzilla-87ea46f7fa2b269f065181f7765352184bb59717.tar.xz |
Bug 574879: Create a test that assures the correctness of Search.pm's
boolean charts
r=glob, a=mkanat
Diffstat (limited to 'xt/lib/Bugzilla/Test/Search/AndTest.pm')
-rw-r--r-- | xt/lib/Bugzilla/Test/Search/AndTest.pm | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/xt/lib/Bugzilla/Test/Search/AndTest.pm b/xt/lib/Bugzilla/Test/Search/AndTest.pm new file mode 100644 index 000000000..d7b21af48 --- /dev/null +++ b/xt/lib/Bugzilla/Test/Search/AndTest.pm @@ -0,0 +1,69 @@ +# -*- 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> + +# This test combines two field/operator combinations using AND in +# a single boolean chart. +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'; + +############# +# Accessors # +############# + +# In an AND test, bugs ARE supposed to be contained only if they are contained +# by ALL tests. +sub bug_is_contained { + my ($self, $number) = @_; + return all { $_->bug_is_contained($number) } $self->field_tests; +} + +######################## +# SKIP & TODO Messages # +######################## + +sub _join_skip { () } +sub _join_broken_constant { {} } + +############################## +# Bugzilla::Search arguments # +############################## + +sub search_params { + my ($self) = @_; + my @all_params = map { $_->search_params } $self->field_tests; + my $params = new Bugzilla::Test::Search::FakeCGI; + 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')); + $chart++; + } + return $params; +} + +1;
\ No newline at end of file |