Lines 84-98
sub setup {
Link Here
|
84 |
{ |
84 |
{ |
85 |
class => 'Koha::Patrons', |
85 |
class => 'Koha::Patrons', |
86 |
value => { |
86 |
value => { |
87 |
surname => "test_patron_" . $i++, |
87 |
surname => "test_patron_" . $i++, |
88 |
firstname => $firstname, |
88 |
firstname => $firstname, |
89 |
middle_name => q{}, # We don't want to copy the logic from patron_to_html |
89 |
preferred_name => $firstname, |
90 |
othernames => q{}, |
90 |
middle_name => q{}, # We don't want to copy the logic from patron_to_html |
91 |
categorycode => $patron_category->categorycode, |
91 |
othernames => q{}, |
92 |
branchcode => $library->branchcode, |
92 |
categorycode => $patron_category->categorycode, |
93 |
borrowernotes => $borrowernotes, |
93 |
branchcode => $library->branchcode, |
94 |
address => $address, |
94 |
borrowernotes => $borrowernotes, |
95 |
email => $email, |
95 |
address => $address, |
|
|
96 |
email => $email, |
96 |
} |
97 |
} |
97 |
} |
98 |
} |
98 |
); |
99 |
); |
Lines 102-116
sub setup {
Link Here
|
102 |
{ |
103 |
{ |
103 |
class => 'Koha::Patrons', |
104 |
class => 'Koha::Patrons', |
104 |
value => { |
105 |
value => { |
105 |
surname => "test", |
106 |
surname => "test", |
106 |
firstname => "not_p_a_t_r_o_n", # won't match 'patron' |
107 |
firstname => "not_p_a_t_r_o_n", # won't match 'patron' |
107 |
middle_name => q{}, # We don't want to copy the logic from patron_to_html |
108 |
preferred_name => "not_p_a_t_r_o_n", |
108 |
othernames => q{}, |
109 |
middle_name => q{}, # We don't want to copy the logic from patron_to_html |
109 |
categorycode => $patron_category->categorycode, |
110 |
othernames => q{}, |
110 |
branchcode => $library->branchcode, |
111 |
categorycode => $patron_category->categorycode, |
111 |
borrowernotes => $borrowernotes, |
112 |
branchcode => $library->branchcode, |
112 |
address => $address, |
113 |
borrowernotes => $borrowernotes, |
113 |
email => $email, |
114 |
address => $address, |
|
|
115 |
email => $email, |
114 |
} |
116 |
} |
115 |
} |
117 |
} |
116 |
); |
118 |
); |
Lines 127-142
sub setup {
Link Here
|
127 |
{ |
129 |
{ |
128 |
class => 'Koha::Patrons', |
130 |
class => 'Koha::Patrons', |
129 |
value => { |
131 |
value => { |
130 |
surname => "test_patron_27", |
132 |
surname => "test_patron_27", |
131 |
firstname => $firstname, |
133 |
firstname => $firstname, |
132 |
middle_name => q{}, # We don't want to copy the logic from patron_to_html |
134 |
preferred_name => $firstname, |
133 |
othernames => q{}, |
135 |
middle_name => q{}, # We don't want to copy the logic from patron_to_html |
134 |
categorycode => $patron_category->categorycode, |
136 |
othernames => q{}, |
135 |
branchcode => $library_2->branchcode, |
137 |
categorycode => $patron_category->categorycode, |
136 |
borrowernotes => $borrowernotes, |
138 |
branchcode => $library_2->branchcode, |
137 |
address => $address, |
139 |
borrowernotes => $borrowernotes, |
138 |
email => $email, |
140 |
address => $address, |
139 |
dateofbirth => '1980-06-17', |
141 |
email => $email, |
|
|
142 |
dateofbirth => '1980-06-17', |
140 |
} |
143 |
} |
141 |
} |
144 |
} |
142 |
); |
145 |
); |
Lines 214-220
subtest 'Search patrons' => sub {
Link Here
|
214 |
C4::Context->set_preference('DefaultPatronSearchFields',""); |
217 |
C4::Context->set_preference('DefaultPatronSearchFields',""); |
215 |
C4::Context->set_preference('DefaultPatronSearchMethod',"contains"); |
218 |
C4::Context->set_preference('DefaultPatronSearchMethod',"contains"); |
216 |
my $searchable_attributes = Koha::Patron::Attribute::Types->search({ staff_searchable => 1 })->count(); |
219 |
my $searchable_attributes = Koha::Patron::Attribute::Types->search({ staff_searchable => 1 })->count(); |
217 |
my $nb_standard_fields = 13 + $searchable_attributes; # Standard fields, plus one searchable attribute |
220 |
my $nb_standard_fields = 14 + $searchable_attributes; # Standard fields, plus one searchable attribute |
218 |
$driver->get( $base_url . "/members/members-home.pl" ); |
221 |
$driver->get( $base_url . "/members/members-home.pl" ); |
219 |
my @adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option'); |
222 |
my @adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option'); |
220 |
is( scalar @adv_options, $nb_standard_fields + 1, 'All standard fields are searchable if DefaultPatronSearchFields not set. middle_name is there.'); |
223 |
is( scalar @adv_options, $nb_standard_fields + 1, 'All standard fields are searchable if DefaultPatronSearchFields not set. middle_name is there.'); |
Lines 225-240
subtest 'Search patrons' => sub {
Link Here
|
225 |
C4::Context->set_preference('DefaultPatronSearchFields',"firstname|initials"); |
228 |
C4::Context->set_preference('DefaultPatronSearchFields',"firstname|initials"); |
226 |
$driver->get( $base_url . "/members/members-home.pl" ); |
229 |
$driver->get( $base_url . "/members/members-home.pl" ); |
227 |
@adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option'); |
230 |
@adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option'); |
228 |
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'); |
231 |
is( scalar @adv_options, $nb_standard_fields - 1, 'New option added when DefaultPatronSearchFields is populated with a field. Note that middle_name and preferred_name disappears, we do not want it if not part of DefaultPatronSearchFields'); |
229 |
is( $adv_options[0]->get_value(), 'standard', 'Standard search uses value "standard"'); |
232 |
is( $adv_options[0]->get_value(), 'standard', 'Standard search uses value "standard"'); |
230 |
@filter_options = $driver->find_elements('//select[@class="searchfieldstype_filter"]/option'); |
233 |
@filter_options = $driver->find_elements('//select[@class="searchfieldstype_filter"]/option'); |
231 |
is( scalar @filter_options, $nb_standard_fields, 'New filter option added when DefaultPatronSearchFields is populated with a field'); |
234 |
is( scalar @filter_options, $nb_standard_fields - 1, 'New filter option added when DefaultPatronSearchFields is populated with a field'); |
232 |
is( $filter_options[0]->get_value(), 'standard', 'Standard filter uses value "standard"'); |
235 |
is( $filter_options[0]->get_value(), 'standard', 'Standard filter uses value "standard"'); |
233 |
$driver->get( $base_url . "/members/members-home.pl" ); |
236 |
$driver->get( $base_url . "/members/members-home.pl" ); |
234 |
@adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option'); |
237 |
@adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option'); |
235 |
@filter_options = $driver->find_elements('//select[@class="searchfieldstype_filter"]/option'); |
238 |
@filter_options = $driver->find_elements('//select[@class="searchfieldstype_filter"]/option'); |
236 |
is( scalar @adv_options, $nb_standard_fields, 'Invalid option not added when DefaultPatronSearchFields is populated with an invalid field'); |
239 |
is( scalar @adv_options, $nb_standard_fields - 1, 'Invalid option not added when DefaultPatronSearchFields is populated with an invalid field'); |
237 |
is( scalar @filter_options, $nb_standard_fields, 'Invalid filter option not added when DefaultPatronSearchFields is populated with an invalid field'); |
240 |
is( scalar @filter_options, $nb_standard_fields - 1, 'Invalid filter option not added when DefaultPatronSearchFields is populated with an invalid field'); |
238 |
|
241 |
|
239 |
# NOTE: We should probably ensure the bad field is removed from 'standard' search here, else searches are broken |
242 |
# NOTE: We should probably ensure the bad field is removed from 'standard' search here, else searches are broken |
240 |
C4::Context->set_preference('DefaultPatronSearchFields',""); |
243 |
C4::Context->set_preference('DefaultPatronSearchFields',""); |
Lines 425-435
subtest 'Search patrons' => sub {
Link Here
|
425 |
my $patron_27 = Koha::Patrons->search( { surname => 'test_patron_27' } )->next; |
428 |
my $patron_27 = Koha::Patrons->search( { surname => 'test_patron_27' } )->next; |
426 |
is( is_patron_shown($patron_27), 1, 'search by correct year shows the patron' ); |
429 |
is( is_patron_shown($patron_27), 1, 'search by correct year shows the patron' ); |
427 |
$dob_search_filter->clear; |
430 |
$dob_search_filter->clear; |
|
|
431 |
$dob_search_filter = $s->driver->find_element( '//table[@id="' . $table_id . '"]//input[@placeholder="Date of birth search"]' ); |
428 |
|
432 |
|
429 |
$dob_search_filter->send_keys('1986'); |
433 |
$dob_search_filter->send_keys('1986'); |
430 |
sleep $DT_delay && $s->wait_for_ajax; |
434 |
sleep $DT_delay && $s->wait_for_ajax; |
431 |
is( is_patron_shown($patron_27), 0, 'search by incorrect year does not show the patron' ); |
435 |
is( is_patron_shown($patron_27), 0, 'search by incorrect year does not show the patron' ); |
432 |
$dob_search_filter->clear; |
436 |
$dob_search_filter->clear; |
|
|
437 |
$dob_search_filter = $s->driver->find_element( '//table[@id="' . $table_id . '"]//input[@placeholder="Date of birth search"]' ); |
433 |
|
438 |
|
434 |
$dob_search_filter->send_keys('1980-06'); |
439 |
$dob_search_filter->send_keys('1980-06'); |
435 |
sleep $DT_delay && $s->wait_for_ajax; |
440 |
sleep $DT_delay && $s->wait_for_ajax; |
436 |
- |
|
|