|
Lines 26-35
our $DT_delay = 1;
Link Here
|
| 26 |
|
26 |
|
| 27 |
END { |
27 |
END { |
| 28 |
unless ( @cleanup ) { say "WARNING: Cleanup failed!" } |
28 |
unless ( @cleanup ) { say "WARNING: Cleanup failed!" } |
| 29 |
C4::Context->set_preference( 'dateformat', $original_dateformat ); |
29 |
Koha::Config::SysPrefs->set_preference( 'dateformat', $original_dateformat ); |
| 30 |
C4::Context->set_preference( 'DefaultPatronSearchFields', $original_DefaultPatronSearchFields ); |
30 |
Koha::Config::SysPrefs->set_preference( 'DefaultPatronSearchFields', $original_DefaultPatronSearchFields ); |
| 31 |
C4::Context->set_preference( 'DefaultPatronSearchMethod', $original_DefaultPatronSearchMethod ); |
31 |
Koha::Config::SysPrefs->set_preference( 'DefaultPatronSearchMethod', $original_DefaultPatronSearchMethod ); |
| 32 |
C4::Context->set_preference( 'PatronsPerPage', $original_PatronsPerPage ); |
32 |
Koha::Config::SysPrefs->set_preference( 'PatronsPerPage', $original_PatronsPerPage ); |
| 33 |
$_->delete for @cleanup; |
33 |
$_->delete for @cleanup; |
| 34 |
}; |
34 |
}; |
| 35 |
|
35 |
|
|
Lines 187-198
subtest 'Search patrons' => sub {
Link Here
|
| 187 |
my $table_id = "memberresultst"; |
187 |
my $table_id = "memberresultst"; |
| 188 |
|
188 |
|
| 189 |
$s->auth; |
189 |
$s->auth; |
| 190 |
C4::Context->set_preference('DefaultPatronSearchFields',""); |
190 |
Koha::Config::SysPrefs->set_preference('DefaultPatronSearchFields',""); |
| 191 |
C4::Context->set_preference('DefaultPatronSearchMethod',"contains"); |
191 |
Koha::Config::SysPrefs->set_preference('DefaultPatronSearchMethod',"contains"); |
| 192 |
my $searchable_attributes = Koha::Patron::Attribute::Types->search({ staff_searchable => 1 })->count(); |
|
|
| 193 |
my $PatronsPerPage = 15; |
192 |
my $PatronsPerPage = 15; |
| 194 |
my $nb_standard_fields = 13 + $searchable_attributes; # Standard fields, plus one searchable attribute |
193 |
my $nb_standard_fields = 13; |
| 195 |
C4::Context->set_preference('PatronsPerPage', $PatronsPerPage); |
194 |
Koha::Config::SysPrefs->set_preference('PatronsPerPage', $PatronsPerPage); |
| 196 |
$driver->get( $base_url . "/members/members-home.pl" ); |
195 |
$driver->get( $base_url . "/members/members-home.pl" ); |
| 197 |
my @adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option'); |
196 |
my @adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option'); |
| 198 |
is( scalar @adv_options, $nb_standard_fields + 1, 'All standard fields are searchable if DefaultPatronSearchFields not set. middle_name is there.'); |
197 |
is( scalar @adv_options, $nb_standard_fields + 1, 'All standard fields are searchable if DefaultPatronSearchFields not set. middle_name is there.'); |
|
Lines 200-206
subtest 'Search patrons' => sub {
Link Here
|
| 200 |
my @filter_options = $driver->find_elements('//select[@id="searchfieldstype_filter"]/option'); |
199 |
my @filter_options = $driver->find_elements('//select[@id="searchfieldstype_filter"]/option'); |
| 201 |
is( scalar @filter_options, $nb_standard_fields + 1, 'All standard fields + middle_name are searchable by filter if DefaultPatronSearchFields not set'); |
200 |
is( scalar @filter_options, $nb_standard_fields + 1, 'All standard fields + middle_name are searchable by filter if DefaultPatronSearchFields not set'); |
| 202 |
is( $filter_options[0]->get_value(), 'standard', 'Standard filter uses hard coded value "standard" DefaultPatronSearchFields not set'); |
201 |
is( $filter_options[0]->get_value(), 'standard', 'Standard filter uses hard coded value "standard" DefaultPatronSearchFields not set'); |
| 203 |
C4::Context->set_preference('DefaultPatronSearchFields',"firstname|initials"); |
202 |
Koha::Config::SysPrefs->set_preference('DefaultPatronSearchFields',"firstname|initials"); |
| 204 |
$driver->get( $base_url . "/members/members-home.pl" ); |
203 |
$driver->get( $base_url . "/members/members-home.pl" ); |
| 205 |
@adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option'); |
204 |
@adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option'); |
| 206 |
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'); |
205 |
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 208-213
subtest 'Search patrons' => sub {
Link Here
|
| 208 |
@filter_options = $driver->find_elements('//select[@id="searchfieldstype_filter"]/option'); |
207 |
@filter_options = $driver->find_elements('//select[@id="searchfieldstype_filter"]/option'); |
| 209 |
is( scalar @filter_options, $nb_standard_fields, 'New filter option added when DefaultPatronSearchFields is populated with a field'); |
208 |
is( scalar @filter_options, $nb_standard_fields, 'New filter option added when DefaultPatronSearchFields is populated with a field'); |
| 210 |
is( $filter_options[0]->get_value(), 'standard', 'Standard filter uses value "standard"'); |
209 |
is( $filter_options[0]->get_value(), 'standard', 'Standard filter uses value "standard"'); |
|
|
210 |
Koha::Config::SysPrefs->set_preference('DefaultPatronSearchFields',"firstname|initials|horses"); |
| 211 |
$driver->get( $base_url . "/members/members-home.pl" ); |
211 |
$driver->get( $base_url . "/members/members-home.pl" ); |
| 212 |
@adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option'); |
212 |
@adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option'); |
| 213 |
@filter_options = $driver->find_elements('//select[@id="searchfieldstype_filter"]/option'); |
213 |
@filter_options = $driver->find_elements('//select[@id="searchfieldstype_filter"]/option'); |
|
Lines 215-221
subtest 'Search patrons' => sub {
Link Here
|
| 215 |
is( scalar @filter_options, $nb_standard_fields, 'Invalid filter option not added when DefaultPatronSearchFields is populated with an invalid field'); |
215 |
is( scalar @filter_options, $nb_standard_fields, 'Invalid filter option not added when DefaultPatronSearchFields is populated with an invalid field'); |
| 216 |
|
216 |
|
| 217 |
# NOTE: We should probably ensure the bad field is removed from 'standard' search here, else searches are broken |
217 |
# NOTE: We should probably ensure the bad field is removed from 'standard' search here, else searches are broken |
| 218 |
C4::Context->set_preference('DefaultPatronSearchFields',""); |
218 |
Koha::Config::SysPrefs->set_preference('DefaultPatronSearchFields',""); |
| 219 |
$driver->get( $base_url . "/members/members-home.pl" ); |
219 |
$driver->get( $base_url . "/members/members-home.pl" ); |
| 220 |
$s->fill_form( { search_patron_filter => 'test_patron' } ); |
220 |
$s->fill_form( { search_patron_filter => 'test_patron' } ); |
| 221 |
$s->submit_form; |
221 |
$s->submit_form; |
|
Lines 328-334
subtest 'Search patrons' => sub {
Link Here
|
| 328 |
|
328 |
|
| 329 |
plan tests => 7; |
329 |
plan tests => 7; |
| 330 |
|
330 |
|
| 331 |
C4::Context->set_preference( 'PatronsPerPage', 5 ); |
331 |
Koha::Config::SysPrefs->set_preference( 'PatronsPerPage', 5 ); |
| 332 |
$driver->get( $base_url . "/members/members-home.pl" ); |
332 |
$driver->get( $base_url . "/members/members-home.pl" ); |
| 333 |
$s->fill_form( { search_patron_filter => 'test_patron' } ); |
333 |
$s->fill_form( { search_patron_filter => 'test_patron' } ); |
| 334 |
$s->submit_form; |
334 |
$s->submit_form; |
|
Lines 378-384
subtest 'Search patrons' => sub {
Link Here
|
| 378 |
subtest 'filter by date of birth' => sub { |
378 |
subtest 'filter by date of birth' => sub { |
| 379 |
plan tests => 7; |
379 |
plan tests => 7; |
| 380 |
|
380 |
|
| 381 |
C4::Context->set_preference( 'dateformat', 'metric' ); |
381 |
Koha::Config::SysPrefs->set_preference( 'dateformat', 'metric' ); |
| 382 |
|
382 |
|
| 383 |
# We have a patron with date of birth=1980-06-17 => formatted as 17/06/1980 |
383 |
# We have a patron with date of birth=1980-06-17 => formatted as 17/06/1980 |
| 384 |
|
384 |
|