Bugzilla – Attachment 29300 Details for
Bug 12443
Initial re-factoring of buildQuery
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12443: (QA followup) Unit tests for _build_initial_query
Bug-12443-QA-followup-Unit-tests-for-buildinitialq.patch (text/plain), 6.81 KB, created by
Tomás Cohen Arazi (tcohen)
on 2014-06-26 18:46:04 UTC
(
hide
)
Description:
Bug 12443: (QA followup) Unit tests for _build_initial_query
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2014-06-26 18:46:04 UTC
Size:
6.81 KB
patch
obsolete
>From 75a5e9fa3dbc820f6248084cb297b890624311ef Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@gmail.com> >Date: Wed, 25 Jun 2014 16:29:18 -0300 >Subject: [PATCH] Bug 12443: (QA followup) Unit tests for _build_initial_query > >This followup adds uint tests for the newly introduced function. >It is really basic, but covers all scenarios for the new function, >and will help us prevent regressions in future patches. > >Regards >To+ > >Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com> >--- > t/Search.t | 161 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 161 insertions(+) > create mode 100755 t/Search.t > >diff --git a/t/Search.t b/t/Search.t >new file mode 100755 >index 0000000..286d36a >--- /dev/null >+++ b/t/Search.t >@@ -0,0 +1,161 @@ >+#!/usr/bin/perl >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use Test::More tests => 3; >+ >+BEGIN { >+ use_ok('C4::Search'); >+ can_ok('C4::Search', >+ qw/_build_initial_query/); >+} >+ >+subtest "_build_initial_query tests" => sub { >+ >+ plan tests => 20; >+ >+ my ($query,$query_cgi,$query_desc,$previous_operand); >+ # all params have values >+ my $params = { >+ query => "query", >+ query_cgi => "query_cgi", >+ query_desc => "query_desc", >+ operator => "operator", >+ parsed_operand => "parsed_operand", >+ original_operand => "original_operand", >+ index => "index", >+ index_plus => "index_plus", >+ indexes_set => "indexes_set", >+ previous_operand => "previous_operand" >+ }; >+ >+ ($query,$query_cgi,$query_desc,$previous_operand) = >+ C4::Search::_build_initial_query($params); >+ is( $query, "query operator parsed_operand", >+ "\$query built correctly"); >+ is( $query_cgi, "query_cgi&op=%20operator%20&idx=index&q=original_operand", >+ "\$query_cgi built correctly"); >+ is( $query_desc, "query_desc operator index_plus original_operand", >+ "\$query_desc build correctly"); >+ is( $previous_operand, "previous_operand", >+ "\$query build correctly"); >+ >+ # no operator >+ $params = { >+ query => "query", >+ query_cgi => "query_cgi", >+ query_desc => "query_desc", >+ operator => undef, >+ parsed_operand => "parsed_operand", >+ original_operand => "original_operand", >+ index => "index", >+ index_plus => "index_plus", >+ indexes_set => "indexes_set", >+ previous_operand => "previous_operand" >+ }; >+ >+ ($query,$query_cgi,$query_desc,$previous_operand) = >+ C4::Search::_build_initial_query($params); >+ is( $query, "query and parsed_operand", >+ "\$query built correctly (no operator)"); >+ is( $query_cgi, "query_cgi&op=%20and%20&idx=index&q=original_operand", >+ "\$query_cgi built correctly (no operator)"); >+ is( $query_desc, "query_desc and index_plus original_operand", >+ "\$query_desc build correctly (no operator)"); >+ is( $previous_operand, "previous_operand", >+ "\$query build correctly (no operator)"); >+ >+ # no previous operand >+ $params = { >+ query => "query", >+ query_cgi => "query_cgi", >+ query_desc => "query_desc", >+ operator => "operator", >+ parsed_operand => "parsed_operand", >+ original_operand => "original_operand", >+ index => "index", >+ index_plus => "index_plus", >+ indexes_set => "indexes_set", >+ previous_operand => undef >+ }; >+ >+ ($query,$query_cgi,$query_desc,$previous_operand) = >+ C4::Search::_build_initial_query($params); >+ is( $query, "queryparsed_operand", >+ "\$query built correctly (no previous operand)"); >+ is( $query_cgi, "query_cgi&idx=index&q=original_operand", >+ "\$query_cgi built correctly (no previous operand)"); >+ is( $query_desc, "query_descindex_plus original_operand", >+ "\$query_desc build correctly (no previous operand)"); >+ is( $previous_operand, 1, >+ "\$query build correctly (no previous operand)"); >+ >+ # no index passed >+ $params = { >+ query => "query", >+ query_cgi => "query_cgi", >+ query_desc => "query_desc", >+ operator => "operator", >+ parsed_operand => "parsed_operand", >+ original_operand => "original_operand", >+ index => undef, >+ index_plus => "index_plus", >+ indexes_set => "indexes_set", >+ previous_operand => "previous_operand" >+ }; >+ >+ ($query,$query_cgi,$query_desc,$previous_operand) = >+ C4::Search::_build_initial_query($params); >+ is( $query, "query operator parsed_operand", >+ "\$query built correctly (no index passed)"); >+ is( $query_cgi, "query_cgi&op=%20operator%20&q=original_operand", >+ "\$query_cgi built correctly (no index passed)"); >+ is( $query_desc, "query_desc operator index_plus original_operand", >+ "\$query_desc build correctly (no index passed)"); >+ is( $previous_operand, "previous_operand", >+ "\$query build correctly (no index passed)"); >+ >+ # no index_plus passed >+ $params = { >+ query => "query", >+ query_cgi => "query_cgi", >+ query_desc => "query_desc", >+ operator => "operator", >+ parsed_operand => "parsed_operand", >+ original_operand => "original_operand", >+ index => "index", >+ index_plus => undef, >+ indexes_set => "indexes_set", >+ previous_operand => "previous_operand" >+ }; >+ >+ ($query,$query_cgi,$query_desc,$previous_operand) = >+ C4::Search::_build_initial_query($params); >+ is( $query, "query operator parsed_operand", >+ "\$query built correctly (no index_plus passed)"); >+ is( $query_cgi, "query_cgi&op=%20operator%20&idx=index&q=original_operand", >+ "\$query_cgi built correctly (no index_plus passed)"); >+ is( $query_desc, "query_desc operator original_operand", >+ "\$query_desc build correctly (no index_plus passed)"); >+ is( $previous_operand, "previous_operand", >+ "\$query build correctly (no index_plus passed)"); >+ >+}; >+ >+ >+1; >-- >1.9.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 12443
:
28917
|
28918
|
28927
|
29116
| 29300