|
Lines 51-57
my $base_url = $s->base_url;
Link Here
|
| 51 |
my $builder = t::lib::TestBuilder->new; |
51 |
my $builder = t::lib::TestBuilder->new; |
| 52 |
|
52 |
|
| 53 |
subtest 'Search patrons' => sub { |
53 |
subtest 'Search patrons' => sub { |
| 54 |
plan tests => 24; |
54 |
plan tests => 25; |
| 55 |
|
55 |
|
| 56 |
if ( Koha::Patrons->search({surname => {-like => "test_patron_%"}})->count ) { |
56 |
if ( Koha::Patrons->search({surname => {-like => "test_patron_%"}})->count ) { |
| 57 |
BAIL_OUT("Cannot run this test, data we need to create already exist in the DB"); |
57 |
BAIL_OUT("Cannot run this test, data we need to create already exist in the DB"); |
|
Lines 132-138
subtest 'Search patrons' => sub {
Link Here
|
| 132 |
description => 'my description1', |
132 |
description => 'my description1', |
| 133 |
} |
133 |
} |
| 134 |
)->store; |
134 |
)->store; |
| 135 |
my $attribute_type_searchable = Koha::Patron::Attribute::Type->new( |
135 |
my $attribute_type_searchable_1 = Koha::Patron::Attribute::Type->new( |
| 136 |
{ |
136 |
{ |
| 137 |
code => 'my code2', |
137 |
code => 'my code2', |
| 138 |
description => 'my description2', |
138 |
description => 'my description2', |
|
Lines 140-152
subtest 'Search patrons' => sub {
Link Here
|
| 140 |
staff_searchable => 1 |
140 |
staff_searchable => 1 |
| 141 |
} |
141 |
} |
| 142 |
)->store; |
142 |
)->store; |
|
|
143 |
my $attribute_type_searchable_2 = Koha::Patron::Attribute::Type->new( |
| 144 |
{ |
| 145 |
code => 'my code3', |
| 146 |
description => 'my description3', |
| 147 |
opac_display => 1, |
| 148 |
staff_searchable => 1 |
| 149 |
} |
| 150 |
)->store; |
| 151 |
|
| 143 |
$patrons[0]->extended_attributes([ |
152 |
$patrons[0]->extended_attributes([ |
| 144 |
{ code => $attribute_type->code, attribute => 'test_attr_1' }, |
153 |
{ code => $attribute_type->code, attribute => 'test_attr_1' }, |
| 145 |
{ code => $attribute_type_searchable->code, attribute => 'test_attr_2'}, |
154 |
{ code => $attribute_type_searchable_1->code, attribute => 'test_attr_2'}, |
|
|
155 |
{ code => $attribute_type_searchable_2->code, attribute => 'yyy'}, |
| 146 |
]); |
156 |
]); |
| 147 |
$patrons[1]->extended_attributes([ |
157 |
$patrons[1]->extended_attributes([ |
| 148 |
{ code => $attribute_type->code, attribute => 'test_attr_1' }, |
158 |
{ code => $attribute_type->code, attribute => 'test_attr_1' }, |
| 149 |
{ code => $attribute_type_searchable->code, attribute => 'test_attr_2'}, |
159 |
{ code => $attribute_type_searchable_1->code, attribute => 'test_attr_2'}, |
|
|
160 |
{ code => $attribute_type_searchable_2->code, attribute => 'yyy'}, |
| 150 |
]); |
161 |
]); |
| 151 |
|
162 |
|
| 152 |
my $total_number_of_patrons = Koha::Patrons->search->count; |
163 |
my $total_number_of_patrons = Koha::Patrons->search->count; |
|
Lines 254-259
subtest 'Search patrons' => sub {
Link Here
|
| 254 |
|
265 |
|
| 255 |
is( $driver->find_element('//div[@id="'.$table_id.'_info"]')->get_text, sprintf('No entries to show (filtered from %s total entries)', $total_number_of_patrons), 'Searching on a non-searchable attribute returns no results' ); |
266 |
is( $driver->find_element('//div[@id="'.$table_id.'_info"]')->get_text, sprintf('No entries to show (filtered from %s total entries)', $total_number_of_patrons), 'Searching on a non-searchable attribute returns no results' ); |
| 256 |
|
267 |
|
|
|
268 |
# clear form |
| 269 |
$driver->find_element('//form[@id="patron_search_form"]//*[@id="clear_search"]')->click(); |
| 270 |
$s->fill_form( { search_patron_filter => 'test_attr yyy' } ); # Terms must be split |
| 271 |
$s->submit_form; |
| 272 |
$s->wait_for_ajax; |
| 273 |
|
| 274 |
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' ); |
| 275 |
|
| 257 |
# clear form |
276 |
# clear form |
| 258 |
$driver->find_element('//form[@id="patron_search_form"]//*[@id="clear_search"]')->click(); |
277 |
$driver->find_element('//form[@id="patron_search_form"]//*[@id="clear_search"]')->click(); |
| 259 |
# Search on searchable attribute, we expect 2 patrons |
278 |
# Search on searchable attribute, we expect 2 patrons |
|
Lines 279-285
subtest 'Search patrons' => sub {
Link Here
|
| 279 |
push @cleanup, $library; |
298 |
push @cleanup, $library; |
| 280 |
push @cleanup, $library_2; |
299 |
push @cleanup, $library_2; |
| 281 |
push @cleanup, $patron_category; |
300 |
push @cleanup, $patron_category; |
| 282 |
push @cleanup, $attribute_type, $attribute_type_searchable; |
301 |
push @cleanup, $attribute_type, $attribute_type_searchable_1, $attribute_type_searchable_2; |
| 283 |
C4::Context->set_preference('DefaultPatronSearchFields',$default_patron_search_fields); |
302 |
C4::Context->set_preference('DefaultPatronSearchFields',$default_patron_search_fields); |
| 284 |
C4::Context->set_preference('PatronsPerPage',$default_patron_per_page); |
303 |
C4::Context->set_preference('PatronsPerPage',$default_patron_per_page); |
| 285 |
|
304 |
|
| 286 |
- |
|
|