Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
bugzilla
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
bugzilla
Commits
20409300
Commit
20409300
authored
Oct 02, 2010
by
Max Kanat-Alexander
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 601376: Test the __all__, __open__, and __closed__ arguments to
bug_status in xt/search.t r=mkanat, a=mkanat (module owner)
parent
b96b7a4b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
7 deletions
+44
-7
Search.pm
xt/lib/Bugzilla/Test/Search.pm
+14
-1
Constants.pm
xt/lib/Bugzilla/Test/Search/Constants.pm
+14
-0
FieldTest.pm
xt/lib/Bugzilla/Test/Search/FieldTest.pm
+1
-1
FieldTestNormal.pm
xt/lib/Bugzilla/Test/Search/FieldTestNormal.pm
+15
-5
No files found.
xt/lib/Bugzilla/Test/Search.pm
View file @
20409300
...
...
@@ -58,6 +58,7 @@ use Bugzilla::FlagType;
use
Bugzilla::
Group
;
use
Bugzilla::
Install
();
use
Bugzilla::Test::Search::
Constants
;
use
Bugzilla::Test::Search::
FieldTestNormal
;
use
Bugzilla::Test::Search::
OperatorTest
;
use
Bugzilla::
User
();
use
Bugzilla::
Util
qw(generate_random_password)
;
...
...
@@ -108,7 +109,11 @@ sub num_tests {
my
$sql_injection_tests
=
scalar
(
@fields
)
*
scalar
(
@top_operators
)
*
scalar
(
@injection_values
)
*
NUM_SEARCH_TESTS
;
return
$operator_field_tests
+
$sql_injection_tests
;
# This @{ [] } thing is the only reasonable way to get a count out of a
# constant array.
my
$special_tests
=
scalar
(
@
{
[
SPECIAL_PARAM_TESTS
]
})
*
TESTS_PER_RUN
;
return
$operator_field_tests
+
$sql_injection_tests
+
$special_tests
;
}
sub
_total_operator_tests
{
...
...
@@ -852,6 +857,14 @@ sub run {
# Even though _setup_bugs set us as an admin, we want to be sure at
# this point that we have an admin with refreshed group memberships.
Bugzilla
->
set_user
(
$self
->
admin
);
foreach
my
$test
(
SPECIAL_PARAM_TESTS
)
{
my
$operator_test
=
new
Bugzilla::Test::Search::
OperatorTest
(
$test
->
{
operator
},
$self
);
my
$field
=
Bugzilla::
Field
->
check
(
$test
->
{
field
});
my
$special_test
=
new
Bugzilla::Test::Search::
FieldTestNormal
(
$operator_test
,
$field
,
$test
);
$special_test
->
run
();
}
foreach
my
$operator
(
$self
->
top_level_operators
)
{
my
$operator_test
=
new
Bugzilla::Test::Search::
OperatorTest
(
$operator
,
$self
);
...
...
xt/lib/Bugzilla/Test/Search/Constants.pm
View file @
20409300
...
...
@@ -48,6 +48,7 @@ our @EXPORT = qw(
OR_SKIP
PG_BROKEN
SKIP_FIELDS
SPECIAL_PARAM_TESTS
SUBSTR_NO_FIELD_ADD
SUBSTR_SIZE
TESTS
...
...
@@ -1248,4 +1249,17 @@ use constant OR_BROKEN => {
},
};
#################
# Special Tests #
#################
use
constant
SPECIAL_PARAM_TESTS
=>
(
{
field
=>
'bug_status'
,
operator
=>
'anyexact'
,
value
=>
'__open__'
,
contains
=>
[
5
]
},
{
field
=>
'bug_status'
,
operator
=>
'anyexact'
,
value
=>
'__closed__'
,
contains
=>
[
1
,
2
,
3
,
4
]
},
{
field
=>
'bug_status'
,
operator
=>
'anyexact'
,
value
=>
'__all__'
,
contains
=>
[
1
,
2
,
3
,
4
,
5
]
},
);
1
;
xt/lib/Bugzilla/Test/Search/FieldTest.pm
View file @
20409300
...
...
@@ -59,7 +59,7 @@ sub field_object { return $_[0]->{field_object} }
# than we need the object.
sub
field
{
my
(
$self
)
=
@_
;
return
$self
->
{
field_name
}
||=
$self
->
field_object
->
name
;
$self
->
{
field_name
}
||=
$self
->
field_object
->
name
;
return
$self
->
{
field_name
};
}
# The Bugzilla::Test::Search object that this is a child of.
...
...
xt/lib/Bugzilla/Test/Search/FieldTestNormal.pm
View file @
20409300
...
...
@@ -26,12 +26,22 @@ use strict;
use
warnings
;
use
base
qw(Bugzilla::Test::Search::FieldTest)
;
# We just clone a FieldTest because that's the best for performance,
# overall--that way we don't have to translate the value again.
use
Scalar::
Util
qw(blessed)
;
# Normally, we just clone a FieldTest because that's the best for performance,
# overall--that way we don't have to translate the value again. However,
# sometimes (like in Bugzilla::Test::Search's direct code) we just want
# to create a FieldTestNormal.
sub
new
{
my
(
$class
,
$field_test
)
=
@_
;
my
$self
=
{
%
$field_test
};
return
bless
$self
,
$class
;
my
$class
=
shift
;
my
(
$first_arg
)
=
@_
;
if
(
blessed
$first_arg
and
$first_arg
->
isa
(
'Bugzilla::Test::Search::FieldTest'
))
{
my
$self
=
{
%
$first_arg
};
return
bless
$self
,
$class
;
}
return
$class
->
SUPER::
new
(
@_
);
}
sub
name
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment