Lines 201-208
subtest 'Search patrons' => sub {
Link Here
|
201 |
my $table_id = "memberresultst"; |
201 |
my $table_id = "memberresultst"; |
202 |
|
202 |
|
203 |
$s->auth; |
203 |
$s->auth; |
204 |
C4::Context->set_preference('DefaultPatronSearchFields',""); |
204 |
Koha::Config::Sysprefs->set_preference('DefaultPatronSearchFields',""); |
205 |
C4::Context->set_preference('DefaultPatronSearchMethod',"contains"); |
205 |
Koha::Config::Sysprefs->set_preference('DefaultPatronSearchMethod',"contains"); |
206 |
my $searchable_attributes = Koha::Patron::Attribute::Types->search({ staff_searchable => 1 })->count(); |
206 |
my $searchable_attributes = Koha::Patron::Attribute::Types->search({ staff_searchable => 1 })->count(); |
207 |
my $nb_standard_fields = 13 + $searchable_attributes; # Standard fields, plus one searchable attribute |
207 |
my $nb_standard_fields = 13 + $searchable_attributes; # Standard fields, plus one searchable attribute |
208 |
$driver->get( $base_url . "/members/members-home.pl" ); |
208 |
$driver->get( $base_url . "/members/members-home.pl" ); |
Lines 212-218
subtest 'Search patrons' => sub {
Link Here
|
212 |
my @filter_options = $driver->find_elements('//select[@class="searchfieldstype_filter"]/option'); |
212 |
my @filter_options = $driver->find_elements('//select[@class="searchfieldstype_filter"]/option'); |
213 |
is( scalar @filter_options, $nb_standard_fields + 1, 'All standard fields + middle_name are searchable by filter if DefaultPatronSearchFields not set'); |
213 |
is( scalar @filter_options, $nb_standard_fields + 1, 'All standard fields + middle_name are searchable by filter if DefaultPatronSearchFields not set'); |
214 |
is( $filter_options[0]->get_value(), 'standard', 'Standard filter uses hard coded value "standard" DefaultPatronSearchFields not set'); |
214 |
is( $filter_options[0]->get_value(), 'standard', 'Standard filter uses hard coded value "standard" DefaultPatronSearchFields not set'); |
215 |
C4::Context->set_preference('DefaultPatronSearchFields',"firstname|initials"); |
215 |
Koha::Config::SysPrefs->set_preference('DefaultPatronSearchFields',"firstname|initials"); |
216 |
$driver->get( $base_url . "/members/members-home.pl" ); |
216 |
$driver->get( $base_url . "/members/members-home.pl" ); |
217 |
@adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option'); |
217 |
@adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option'); |
218 |
is( scalar @adv_options, $nb_standard_fields, 'New option added when DefaultPatronSearchFields is populated with a field. Note that middle_name disappears, we do not want it if not part of DefaultPatronSearchFields'); |
218 |
is( scalar @adv_options, $nb_standard_fields, 'New option added when DefaultPatronSearchFields is populated with a field. Note that middle_name disappears, we do not want it if not part of DefaultPatronSearchFields'); |
Lines 220-225
subtest 'Search patrons' => sub {
Link Here
|
220 |
@filter_options = $driver->find_elements('//select[@class="searchfieldstype_filter"]/option'); |
220 |
@filter_options = $driver->find_elements('//select[@class="searchfieldstype_filter"]/option'); |
221 |
is( scalar @filter_options, $nb_standard_fields, 'New filter option added when DefaultPatronSearchFields is populated with a field'); |
221 |
is( scalar @filter_options, $nb_standard_fields, 'New filter option added when DefaultPatronSearchFields is populated with a field'); |
222 |
is( $filter_options[0]->get_value(), 'standard', 'Standard filter uses value "standard"'); |
222 |
is( $filter_options[0]->get_value(), 'standard', 'Standard filter uses value "standard"'); |
|
|
223 |
Koha::Config::SysPrefs->set_preference('DefaultPatronSearchFields',"firstname|initials|horses"); |
223 |
$driver->get( $base_url . "/members/members-home.pl" ); |
224 |
$driver->get( $base_url . "/members/members-home.pl" ); |
224 |
@adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option'); |
225 |
@adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option'); |
225 |
@filter_options = $driver->find_elements('//select[@class="searchfieldstype_filter"]/option'); |
226 |
@filter_options = $driver->find_elements('//select[@class="searchfieldstype_filter"]/option'); |
Lines 227-233
subtest 'Search patrons' => sub {
Link Here
|
227 |
is( scalar @filter_options, $nb_standard_fields, 'Invalid filter option not added when DefaultPatronSearchFields is populated with an invalid field'); |
228 |
is( scalar @filter_options, $nb_standard_fields, 'Invalid filter option not added when DefaultPatronSearchFields is populated with an invalid field'); |
228 |
|
229 |
|
229 |
# NOTE: We should probably ensure the bad field is removed from 'standard' search here, else searches are broken |
230 |
# NOTE: We should probably ensure the bad field is removed from 'standard' search here, else searches are broken |
230 |
C4::Context->set_preference('DefaultPatronSearchFields',""); |
231 |
Koha::Config::SysPrefs->set_preference('DefaultPatronSearchFields',""); |
231 |
$driver->get( $base_url . "/members/members-home.pl" ); |
232 |
$driver->get( $base_url . "/members/members-home.pl" ); |
232 |
$s->fill_form( { 'class=search_patron_filter' => 'test_patron' } ); |
233 |
$s->fill_form( { 'class=search_patron_filter' => 'test_patron' } ); |
233 |
$s->submit_form; |
234 |
$s->submit_form; |
Lines 340-346
subtest 'Search patrons' => sub {
Link Here
|
340 |
|
341 |
|
341 |
plan tests => 7; |
342 |
plan tests => 7; |
342 |
|
343 |
|
343 |
C4::Context->set_preference( 'PatronsPerPage', 5 ); |
344 |
Koha::Config::SysPrefs->set_preference( 'PatronsPerPage', 5 ); |
344 |
$driver->get( $base_url . "/members/members-home.pl" ); |
345 |
$driver->get( $base_url . "/members/members-home.pl" ); |
345 |
$s->fill_form( { 'class=search_patron_filter' => 'test_patron' } ); |
346 |
$s->fill_form( { 'class=search_patron_filter' => 'test_patron' } ); |
346 |
$s->submit_form; |
347 |
$s->submit_form; |
Lines 390-396
subtest 'Search patrons' => sub {
Link Here
|
390 |
subtest 'filter by date of birth' => sub { |
391 |
subtest 'filter by date of birth' => sub { |
391 |
plan tests => 7; |
392 |
plan tests => 7; |
392 |
|
393 |
|
393 |
C4::Context->set_preference( 'dateformat', 'metric' ); |
394 |
Koha::Config::SysPrefs->set_preference( 'dateformat', 'metric' ); |
394 |
|
395 |
|
395 |
# We have a patron with date of birth=1980-06-17 => formatted as 17/06/1980 |
396 |
# We have a patron with date of birth=1980-06-17 => formatted as 17/06/1980 |
396 |
|
397 |
|