Lines 61-67
my $builder = t::lib::TestBuilder->new;
Link Here
|
61 |
my $schema = Koha::Database->schema; |
61 |
my $schema = Koha::Database->schema; |
62 |
|
62 |
|
63 |
subtest 'Search patrons' => sub { |
63 |
subtest 'Search patrons' => sub { |
64 |
plan tests => 27; |
64 |
plan tests => 28; |
65 |
|
65 |
|
66 |
if ( Koha::Patrons->search({surname => {-like => "test_patron_%"}})->count ) { |
66 |
if ( Koha::Patrons->search({surname => {-like => "test_patron_%"}})->count ) { |
67 |
BAIL_OUT("Cannot run this test, data we need to create already exist in the DB"); |
67 |
BAIL_OUT("Cannot run this test, data we need to create already exist in the DB"); |
Lines 152-158
subtest 'Search patrons' => sub {
Link Here
|
152 |
searched_by_default => 0 |
152 |
searched_by_default => 0 |
153 |
} |
153 |
} |
154 |
)->store; |
154 |
)->store; |
155 |
my $attribute_type_searchable = Koha::Patron::Attribute::Type->new( |
155 |
my $attribute_type_searchable_1 = Koha::Patron::Attribute::Type->new( |
156 |
{ |
156 |
{ |
157 |
code => 'my code2', |
157 |
code => 'my code2', |
158 |
description => 'my description2', |
158 |
description => 'my description2', |
Lines 161-186
subtest 'Search patrons' => sub {
Link Here
|
161 |
searched_by_default => 1 |
161 |
searched_by_default => 1 |
162 |
} |
162 |
} |
163 |
)->store; |
163 |
)->store; |
164 |
my $attribute_type_searchable_not_default = Koha::Patron::Attribute::Type->new( |
164 |
my $attribute_type_searchable_2 = Koha::Patron::Attribute::Type->new( |
165 |
{ |
165 |
{ |
166 |
code => 'mycode3', |
166 |
code => 'my code3', |
167 |
description => 'my description3', |
167 |
description => 'my description3', |
168 |
opac_display => 1, |
168 |
opac_display => 1, |
169 |
staff_searchable => 1, |
169 |
staff_searchable => 1, |
|
|
170 |
searched_by_default => 1 |
171 |
} |
172 |
)->store; |
173 |
my $attribute_type_searchable_not_default = Koha::Patron::Attribute::Type->new( |
174 |
{ |
175 |
code => 'mycode4', |
176 |
description => 'my description4', |
177 |
opac_display => 1, |
178 |
staff_searchable => 1, |
170 |
searched_by_default => 0 |
179 |
searched_by_default => 0 |
171 |
} |
180 |
} |
172 |
)->store; |
181 |
)->store; |
173 |
push @cleanup, $attribute_type, $attribute_type_searchable, $attribute_type_searchable_not_default; |
182 |
push @cleanup, $attribute_type, $attribute_type_searchable_1, $attribute_type_searchable_2, $attribute_type_searchable_not_default; |
174 |
|
183 |
|
175 |
$patrons[0]->extended_attributes([ |
184 |
$patrons[0]->extended_attributes([ |
176 |
{ code => $attribute_type->code, attribute => 'test_attr_1' }, |
185 |
{ code => $attribute_type->code, attribute => 'test_attr_1' }, |
177 |
{ code => $attribute_type_searchable->code, attribute => 'test_attr_2'}, |
186 |
{ code => $attribute_type_searchable_1->code, attribute => 'test_attr_2'}, |
178 |
{ code => $attribute_type_searchable_not_default->code, attribute => 'test_attr_3'}, |
187 |
{ code => $attribute_type_searchable_2->code, attribute => 'test_attr_3'}, |
|
|
188 |
{ code => $attribute_type_searchable_not_default->code, attribute => 'test_attr_4'}, |
179 |
]); |
189 |
]); |
180 |
$patrons[1]->extended_attributes([ |
190 |
$patrons[1]->extended_attributes([ |
181 |
{ code => $attribute_type->code, attribute => 'test_attr_1' }, |
191 |
{ code => $attribute_type->code, attribute => 'test_attr_1' }, |
182 |
{ code => $attribute_type_searchable->code, attribute => 'test_attr_2'}, |
192 |
{ code => $attribute_type_searchable_1->code, attribute => 'test_attr_2'}, |
183 |
{ code => $attribute_type_searchable_not_default->code, attribute => 'test_attr_3'}, |
193 |
{ code => $attribute_type_searchable_2->code, attribute => 'test_attr_3'}, |
|
|
194 |
{ code => $attribute_type_searchable_not_default->code, attribute => 'test_attr_4'}, |
184 |
]); |
195 |
]); |
185 |
|
196 |
|
186 |
my $total_number_of_patrons = Koha::Patrons->search->count; |
197 |
my $total_number_of_patrons = Koha::Patrons->search->count; |
Lines 304-311
subtest 'Search patrons' => sub {
Link Here
|
304 |
# clear form |
315 |
# clear form |
305 |
$driver->find_element('//form[@id="patron_search_form"]//*[@id="clear_search"]')->click(); |
316 |
$driver->find_element('//form[@id="patron_search_form"]//*[@id="clear_search"]')->click(); |
306 |
|
317 |
|
|
|
318 |
$s->fill_form( { search_patron_filter => 'test_attr_3' } ); # Terms must be split |
319 |
$s->submit_form; |
320 |
sleep $DT_delay && $s->wait_for_ajax; |
321 |
|
322 |
is( $driver->find_element('//div[@id="'.$table_id.'_info"]')->get_text, sprintf('Showing 1 to %s of %s entries (filtered from %s total entries)', 2, 2, $total_number_of_patrons), 'Searching on a searchable attribute returns correct results' ); |
323 |
|
324 |
# clear form |
325 |
$driver->find_element('//form[@id="patron_search_form"]//*[@id="clear_search"]')->click(); |
326 |
|
307 |
# Search on searchable attribute as specific field, we expect 2 patrons |
327 |
# Search on searchable attribute as specific field, we expect 2 patrons |
308 |
$s->fill_form( { search_patron_filter => 'test_attr_3' } ); |
328 |
$s->fill_form( { search_patron_filter => 'test_attr_4' } ); |
309 |
$driver->find_element('//form[@id="patron_search_form"]//*[@id="searchfieldstype_filter"]//option[@value="_ATTR_'.$attribute_type_searchable_not_default->code.'"]')->click(); |
329 |
$driver->find_element('//form[@id="patron_search_form"]//*[@id="searchfieldstype_filter"]//option[@value="_ATTR_'.$attribute_type_searchable_not_default->code.'"]')->click(); |
310 |
$s->submit_form; |
330 |
$s->submit_form; |
311 |
sleep $DT_delay && $s->wait_for_ajax; |
331 |
sleep $DT_delay && $s->wait_for_ajax; |
312 |
- |
|
|