Bugzilla – Attachment 96343 Details for
Bug 17374
Make use of fields from syspref 'DefaultPatronSearchFields' in patron search fields dropdown
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17374: (follow-up) Unit tests and remove warns
Bug-17374-follow-up-Unit-tests-and-remove-warns.patch (text/plain), 6.54 KB, created by
Nick Clemens (kidclamp)
on 2019-12-16 14:41:21 UTC
(
hide
)
Description:
Bug 17374: (follow-up) Unit tests and remove warns
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2019-12-16 14:41:21 UTC
Size:
6.54 KB
patch
obsolete
>From dea7caa09bfe067580e4ed5901e0bd827a7da3e0 Mon Sep 17 00:00:00 2001 >From: Nick <nick@bywatersolutions.com> >Date: Wed, 30 Oct 2019 14:07:02 +0000 >Subject: [PATCH] Bug 17374: (follow-up) Unit tests and remove warns > >Signed-off-by: Maxime Dufresne <maxime.dufresne@inlibro.com> >--- > C4/Utils/DataTables/Members.pm | 2 -- > members/member.pl | 1 - > t/db_dependent/Utils/Datatables_Members.t | 22 ++++++++++++++++++++-- > t/db_dependent/selenium/patrons_search.t | 22 +++++++++++++++++++++- > 4 files changed, 41 insertions(+), 6 deletions(-) > >diff --git a/C4/Utils/DataTables/Members.pm b/C4/Utils/DataTables/Members.pm >index 5c54fe0c16..4488514b7c 100644 >--- a/C4/Utils/DataTables/Members.pm >+++ b/C4/Utils/DataTables/Members.pm >@@ -14,7 +14,6 @@ sub search { > my $branchcode = $params->{branchcode}; > my $searchtype = $params->{searchtype} || 'contain'; > my $searchfieldstype = $params->{searchfieldstype} || 'standard'; >- warn $searchfieldstype; > my $dt_params = $params->{dt_params}; > > unless ( $searchmember ) { >@@ -146,7 +145,6 @@ sub search { > > my $where; > $where = " WHERE " . join (" AND ", @where_strs) if @where_strs; >- warn $where; > my $orderby = dt_build_orderby($dt_params); > > my $limit; >diff --git a/members/member.pl b/members/member.pl >index a495b21256..2c136c3c9b 100755 >--- a/members/member.pl >+++ b/members/member.pl >@@ -65,7 +65,6 @@ if ( $quicksearch and $searchmember ) { > } > > my $searchfieldstype = $input->param('searchfieldstype') || 'standard'; >-warn "script type $searchfieldstype"; > $template->param( 'alphabet' => C4::Context->preference('alphabet') || join ' ', 'A' .. 'Z' ); > > my $view = $input->request_method() eq "GET" ? "show_form" : "show_results"; >diff --git a/t/db_dependent/Utils/Datatables_Members.t b/t/db_dependent/Utils/Datatables_Members.t >index d378f8fe97..feca4f88fc 100644 >--- a/t/db_dependent/Utils/Datatables_Members.t >+++ b/t/db_dependent/Utils/Datatables_Members.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 50; >+use Test::More tests => 51; > > use C4::Context; > use C4::Members; >@@ -57,7 +57,8 @@ my $john_doe = $builder->build({ > surname => 'Doe', > branchcode => $branchcode, > dateofbirth => '1983-03-01', >- userid => 'john.doe' >+ userid => 'john.doe', >+ initials => 'pacman' > }, > }); > >@@ -113,6 +114,8 @@ my %dt_params = ( > iDisplayStart => 0 > ); > >+t::lib::Mocks::mock_preference('DefaultPatronSearchFields', ''); >+ > # Search "John Doe" > my $search_results = C4::Utils::DataTables::Members::search({ > searchmember => "John Doe", >@@ -461,5 +464,20 @@ subtest 'ExtendedPatronAttributes' => sub { > "'Dupont' is contained in 2 surnames and a patron attribute. Patron attribute one should not be displayed if searching in specific fields (Bug 18094)"); > }; > >+subtest 'Search by any borrowers field (bug 17374)' => sub { >+ plan tests => 2; >+ >+ my $search_results = C4::Utils::DataTables::Members::search({ >+ searchmember => "pacman", >+ searchfieldstype => 'initials', >+ searchtype => 'contain', >+ branchcode => $branchcode, >+ dt_params => \%dt_params >+ }); >+ is( $search_results->{ iTotalDisplayRecords }, 1, "We find only 1 patron when searching for initials 'pacman'" ); >+ >+ is( $search_results->{ patrons }[0]->{ cardnumber }, $john_doe->{cardnumber}, "We find the correct patron when sesrching by initials" ) >+}; >+ > # End > $schema->storage->txn_rollback; >diff --git a/t/db_dependent/selenium/patrons_search.t b/t/db_dependent/selenium/patrons_search.t >index 1d8cd98e48..c0ec35764b 100644 >--- a/t/db_dependent/selenium/patrons_search.t >+++ b/t/db_dependent/selenium/patrons_search.t >@@ -40,7 +40,7 @@ my $builder = t::lib::TestBuilder->new; > > our @cleanup; > subtest 'Search patrons' => sub { >- plan tests => 6; >+ plan tests => 12; > > my @patrons; > my $borrowernotes = q|<strong>just 'a" note</strong> \123 â¤|; >@@ -58,6 +58,7 @@ subtest 'Search patrons' => sub { > my $library = $builder->build_object( > { class => 'Koha::Libraries', value => { branchname => $branchname } } > ); >+ my $default_patron_search_fields = C4::Context->preference('DefaultPatronSearchFields'); > for my $i ( 1 .. 25 ) { > push @patrons, > $builder->build_object( >@@ -77,7 +78,25 @@ subtest 'Search patrons' => sub { > } > > $s->auth; >+ C4::Context->set_preference('DefaultPatronSearchFields',""); > $driver->get( $base_url . "/members/members-home.pl" ); >+ my @adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option'); >+ my @filter_options = $driver->find_elements('//select[@id="searchfieldstype_filter"]/option'); >+ is( scalar @adv_options, 11, 'All standard fields are searchable if DefaultPatronSearchFields not set'); >+ is( scalar @filter_options, 11, 'All standard fields are searchable by filter if DefaultPatronSearchFields not set'); >+ C4::Context->set_preference('DefaultPatronSearchFields',"initials"); >+ $driver->get( $base_url . "/members/members-home.pl" ); >+ @adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option'); >+ @filter_options = $driver->find_elements('//select[@id="searchfieldstype_filter"]/option'); >+ is( scalar @adv_options, 12, 'New option added when DefaultPatronSearchFields is populated with a field'); >+ is( scalar @filter_options, 12, 'New filter option added when DefaultPatronSearchFields is populated with a field'); >+ C4::Context->set_preference('DefaultPatronSearchFields',"initials,horses"); >+ $driver->get( $base_url . "/members/members-home.pl" ); >+ @adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option'); >+ @filter_options = $driver->find_elements('//select[@id="searchfieldstype_filter"]/option'); >+ is( scalar @adv_options, 12, 'Invalid option not added when DefaultPatronSearchFields is populated with an invalid field'); >+ is( scalar @filter_options, 12, 'Invalid filter option not added when DefaultPatronSearchFields is populated with an invalid field'); >+ C4::Context->set_preference('DefaultPatronSearchFields',""); > $s->fill_form( { searchmember_filter => 'test_patron' } ); > $s->submit_form; > my $first_patron = $patrons[0]; >@@ -114,6 +133,7 @@ subtest 'Search patrons' => sub { > push @cleanup, $_ for @patrons; > push @cleanup, $library; > push @cleanup, $patron_category; >+ C4::Context->set_preference('DefaultPatronSearchFields',$default_patron_search_fields); > }; > > END { >-- >2.11.0
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 17374
:
56921
|
56931
|
56958
|
58239
|
66400
|
70226
|
71536
|
71597
|
71598
|
71599
|
71600
|
74828
|
93226
|
94831
|
94876
|
94890
|
94891
|
94892
|
96341
|
96342
|
96343
|
96679
|
98106
|
98478
|
100436
|
100437
|
100438
|
100439