summaryrefslogtreecommitdiffstats
path: root/xt/lib/Bugzilla/Test/Search/OrTest.pm
diff options
context:
space:
mode:
Diffstat (limited to 'xt/lib/Bugzilla/Test/Search/OrTest.pm')
-rw-r--r--xt/lib/Bugzilla/Test/Search/OrTest.pm68
1 files changed, 19 insertions, 49 deletions
diff --git a/xt/lib/Bugzilla/Test/Search/OrTest.pm b/xt/lib/Bugzilla/Test/Search/OrTest.pm
index 42dc30698..b1dbf646c 100644
--- a/xt/lib/Bugzilla/Test/Search/OrTest.pm
+++ b/xt/lib/Bugzilla/Test/Search/OrTest.pm
@@ -25,7 +25,7 @@ package Bugzilla::Test::Search::OrTest;
use base qw(Bugzilla::Test::Search::FieldTest);
use Bugzilla::Test::Search::Constants;
-use List::MoreUtils qw(any uniq);
+use List::MoreUtils qw(all any uniq);
use constant type => 'OR';
@@ -70,16 +70,8 @@ sub debug_value {
# SKIP & TODO Messages #
########################
-sub _join_skip { () }
-sub _join_broken_constant { OR_BROKEN }
-
sub field_not_yet_implemented {
my ($self) = @_;
- foreach my $test ($self->field_tests) {
- if (grep { $_ eq $test->field } $self->_join_skip) {
- return $test->field . " is not yet supported in OR tests";
- }
- }
return $self->_join_messages('field_not_yet_implemented');
}
sub invalid_field_operator_combination {
@@ -100,17 +92,13 @@ sub _join_messages {
sub _bug_will_actually_be_contained {
my ($self, $number) = @_;
- my @results;
+
foreach my $test ($self->field_tests) {
- if ($test->bug_is_contained($number)
- and !$test->contains_known_broken($number))
- {
- return 1;
- }
- elsif (!$test->bug_is_contained($number)
- and $test->contains_known_broken($number)) {
- return 1;
- }
+ # Some tests are broken in such a way that they actually
+ # generate no criteria in the SQL. In this case, the only way
+ # the test contains the bug is if *another* test contains it.
+ next if $test->_known_broken->{no_criteria};
+ return 1 if $test->will_actually_contain_bug($number);
}
return 0;
}
@@ -118,46 +106,28 @@ sub _bug_will_actually_be_contained {
sub contains_known_broken {
my ($self, $number) = @_;
- my $join_broken = $self->_join_known_broken;
- if (my $contains = $join_broken->{contains}) {
- my $contains_is_broken = grep { $_ == $number } @$contains;
- if ($contains_is_broken) {
- my $name = $self->name;
- return "$name contains $number is broken";
- }
- return undef;
- }
-
- return $self->_join_contains_known_broken($number);
-}
-
-sub _join_contains_known_broken {
- my ($self, $number) = @_;
-
if ( ( $self->bug_is_contained($number)
and !$self->_bug_will_actually_be_contained($number) )
or ( !$self->bug_is_contained($number)
and $self->_bug_will_actually_be_contained($number) ) )
{
- my @messages = map { $_->contains_known_broken($number) } $self->field_tests;
+ my @messages = map { $_->contains_known_broken($number) }
+ $self->field_tests;
@messages = grep { $_ } @messages;
+ # Sometimes, with things that break because of no_criteria, there won't
+ # be anything in @messages even though we need to print out a message.
+ if (!@messages) {
+ my @no_criteria = grep { $_->_known_broken->{no_criteria} }
+ $self->field_tests;
+ @messages = map { "No criteria generated by " . $_->name }
+ @no_criteria;
+ }
+ die "broken test with no message" if !@messages;
return join(' AND ', @messages);
}
return undef;
}
-sub _join_known_broken {
- my ($self) = @_;
- my $or_broken = $self->_join_broken_constant;
- foreach my $test ($self->field_tests) {
- @or_broken_for = map { $_->join_broken($or_broken) } $self->field_tests;
- @or_broken_for = grep { defined $_ } @or_broken_for;
- last if !@or_broken_for;
- $or_broken = $or_broken_for[0];
- }
- return $or_broken;
-}
-
##############################
# Bugzilla::Search arguments #
##############################
@@ -182,4 +152,4 @@ sub search_params {
return \%params;
}
-1; \ No newline at end of file
+1;